Click here to Skip to main content
15,886,769 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRemove menu toolbar from MDI Pin
mesajflaviu18-May-10 19:22
mesajflaviu18-May-10 19:22 
AnswerRe: Remove menu toolbar from MDI Pin
Fishyu18-May-10 23:39
Fishyu18-May-10 23:39 
GeneralRe: Remove menu toolbar from MDI Pin
mesajflaviu20-May-10 7:09
mesajflaviu20-May-10 7:09 
GeneralRe: Remove menu toolbar from MDI Pin
mesajflaviu20-May-10 19:43
mesajflaviu20-May-10 19:43 
QuestionProcess run as administrator Pin
ShilpiP18-May-10 18:47
ShilpiP18-May-10 18:47 
AnswerRe: Process run as administrator Pin
Xeqtr18-May-10 22:00
Xeqtr18-May-10 22:00 
QuestionRe: Process run as administrator Pin
David Crow19-May-10 5:41
David Crow19-May-10 5:41 
QuestionObject Oriented c++ Visual Studio Problem. Pin
RobNO18-May-10 12:16
professionalRobNO18-May-10 12:16 
Hey Everyone. My problem is it seems that when I create a .cpp file for a .hpp, when dealing with inheritance, I get the same error which is :

5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2146: syntax error : missing ';' before identifier 'GeoGroup'
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2470: 'GeoGroup' : looks like a function definition, but there is no parameter list; skipping apparent body
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.hpp(20) : error C2059: syntax error : 'public'
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(14) : error C2653: 'GeoGroup' : is not a class or namespace name
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(15) : error C2270: 'draw' : modifiers not allowed on nonmember functions
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(16) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(16) : error C2228: left of '.size' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2227: left of '->move' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(18) : error C2065: 'refpoint' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(19) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(19) : error C2227: left of '->draw' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2227: left of '->move' must point to class/struct/union/generic type
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(20) : error C2065: 'refpoint' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(27) : error C2653: 'GeoGroup' : is not a class or namespace name
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2228: left of '.begin' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(32) : error C2228: left of '.end' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(33) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(33) : error C2228: left of '.end' must have class/struct/union
5> type is ''unknown-type''
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(35) : error C2065: 'elems' : undeclared identifier
5>c:\users\rob\school work\information technology\computer programming with c++\projects\inherit_1\inherit_5\geogroup.cpp(35) : error C2228: left of '.erase' must have class/struct/union
5> type is ''unknown-type''

here is an example of what I am trying to get complied:

the header file
//inherit/geogroup.hpp

#ifndef GEOGROUP_HPP
#define GEOGROUP_HPP

//include header file for the base class
#include "geo.hpp"

//header for the internal management of the elements
#include <vector>

namespace Geo
{
	/*class GeoGroup
	 *	-derived from GeoObj
	 *	-a GeoGroup Consists of
	 *		-A reference point (inherited)
	 *		-A collection of geometric elements (new)
	 */
	Class GeoGroup : public GeoObj
	{
	protected:
		std::vector<GeoObj*> elems;		//collection of pointers to GeoObjs

	public:
		//constructor with optional reference point
		GeoGroup(const Coord& p = Coord(0,0)) : GeoObj(p)
		{
		}

		//output (now also implemented)
		virtual void draw() const;

		//insert element
		virtual void add(GeoObj&);

		//remove element
		virtual bool remove(GeoObj&);

		//virtual destructor
		virtual ~GeoGroup()
		{
		}
	};

}//*****END namespace GeoGroup*****

#endif		//GEOGROUP_HPP


and the dotC file:
//inherit/geogroup.cpp

//include header class
#include "geogroup.hpp"

//header for algorithms
#include <algorithm>

namespace Geo
{
	/*add
	 *	-insert elements
	 */
	void GeoGroup::draw() const
	{
		for (unsigned i = 0 ; i < elems.size(); ++i)
		{
			elems[i]->move(refpoint);		//add offset for the reference point
			elems[i]->draw();				//draw element
			elems[i]->move(-refpoint);		//subtract offset
		}
	}

	/*remove
	 *	- delete element
	 */
	bool GeoGroup::remove(GeoObj& obj)
	{
		//find first element with this address and remove it
		//return whether an object was found and removed
		std::vector<GeoObj*>::iterator pos;
		pos = std::find(elems.begin(), elems.end(), &obj);
		if (pos != elems.end())
		{
			elems.erase(pos);
			return true;
		}
		else
		{
			return false;
		}
	}
}


This seems to me to be a linking problem, and also I realized that I might have something to do with having multiple .hpp and multiple .cpp implementation files.
Anyone have an idea on what I am doing wrong?Confused | :confused:

Thanks,
RobNO.
AnswerRe: Object Oriented c++ Visual Studio Problem. Pin
Graham Breach18-May-10 12:27
Graham Breach18-May-10 12:27 
GeneralRe: Object Oriented c++ Visual Studio Problem. Pin
RobNO18-May-10 12:48
professionalRobNO18-May-10 12:48 
AnswerRe: Object Oriented c++ Visual Studio Problem. Pin
Luc Pattyn18-May-10 13:23
sitebuilderLuc Pattyn18-May-10 13:23 
AnswerRe: Object Oriented c++ Visual Studio Problem. Pin
xtofl18-May-10 22:26
xtofl18-May-10 22:26 
QuestionLarge Menu Items Pin
cryptoknight1718-May-10 12:14
cryptoknight1718-May-10 12:14 
AnswerRe: Large Menu Items Pin
Code-o-mat18-May-10 21:45
Code-o-mat18-May-10 21:45 
GeneralRe: Large Menu Items Pin
cryptoknight1719-May-10 9:38
cryptoknight1719-May-10 9:38 
GeneralRe: Large Menu Items Pin
Code-o-mat19-May-10 11:28
Code-o-mat19-May-10 11:28 
GeneralRe: Large Menu Items Pin
cryptoknight1719-May-10 12:22
cryptoknight1719-May-10 12:22 
QuestionSave/Restore "state" of document in CHtmlView Pin
nobaq18-May-10 5:52
nobaq18-May-10 5:52 
QuestionClass Custom Control Pin
AbhiHcl18-May-10 2:33
AbhiHcl18-May-10 2:33 
AnswerRe: Class Custom Control PinPopular
Iain Clarke, Warrior Programmer18-May-10 2:42
Iain Clarke, Warrior Programmer18-May-10 2:42 
GeneralRe: Class Custom Control Pin
AbhiHcl18-May-10 23:57
AbhiHcl18-May-10 23:57 
GeneralRe: Class Custom Control Pin
Iain Clarke, Warrior Programmer19-May-10 1:58
Iain Clarke, Warrior Programmer19-May-10 1:58 
QuestionVisual Studio Addin for source code editor tooltip [modified] Pin
lclarsen18-May-10 1:58
lclarsen18-May-10 1:58 
QuestionMemory leak In Excel range pointer Pin
trioum18-May-10 0:53
trioum18-May-10 0:53 
AnswerRe: Memory leak In Excel range pointer Pin
Stephen Hewitt18-May-10 14:06
Stephen Hewitt18-May-10 14:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.