|
-
April 21st, 1999, 03:58 AM
#1
Error in new class that base class is CObject
In VC++ 6.0,
I have been created a DLL in Regular DLL using shared MFC DLL.
I would like to create some new class that base class is CObject.
But when I compiled the DLL, errors was occured as follows.
class CMyApp : public CWinApp
{
public:
CMyApp();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CGroveDLLApp)
//}}AFX_VIRTUAL
//{{AFX_MSG(CGroveDLLApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
class CMyObject : public CObject
{
public:
CMyObject();
CMyObject(Node node);
// Attributes
public:
Node* MyNode;
.....
.....
};
Error was occurred in CMyObject(Node node);.
Error message was "error C2629: unexpected 'class CMyObject ('".
How can I create a new class that base class is CObject?
Help me!
-
April 21st, 1999, 04:44 AM
#2
Re: Error in new class that base class is CObject
I also have that error sometimes. Most of the time the error means that there's something in your declaration that's not defined yet. I think that you haven't include the definition of your Node-class. If you don't want to include it then use a forward declaration like this : class Node;
-
April 21st, 1999, 04:48 AM
#3
Re: Error in new class that base class is CObject
This is a typical misleading VC++ compiler error. It's actually telling you that it doesn't know what 'Node' is. You must provide a declaration of Node prior to your CMyObject declaration. If you pass the Node to the CMyObject constructor by reference, you can get away with just a forward declaration:
class Node; // Forward declaration - header can go in CMyObject .cpp file
class CMyObject : public CObject
{
public:
CMyObject();
CMyObject(Node& node); // Pass by reference avoids #including Node header
// Attributes
public:
Node* MyNode;
.....
.....
};
Hope this helps,
Dave
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|