|
-
April 14th, 1999, 04:04 AM
#1
allocating memory on the free store in VC++
I am having some difficulties allocating memory on the free store when using the 'new' keyword. What I have is one class called BigClass for example. And BigClass has a public member variable pointer to another class. eg my code looks something like this in BigClass.h
public:
class OtherClass* m_pcOther; //The pointer to the other class
now in the BigClass.cpp I am trying to allocate memory for the pointer by using something like
m_pcOther = new OtherClass;
It compiles fine but I get a link error that does not look friendly. I have included it below:
error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall OtherClass::GetRuntimeClass(void)const " (?GetRuntimeClass@OtherClass@@UBEPAUCRuntimeClass@@XZ)
If anyone knows how to deal with this, I would appreciate it very much. Thanks in advance,
Thomas
-
April 14th, 1999, 04:17 AM
#2
Re: allocating memory on the free store in VC++
You don't say, but I'd guess OtherClass is derived from CObject? It looks like you are using serialisation or MFC's run-time typing but you haven't used the appropriate macros to declare and define the methods required.
Look at DECLARE_DYNAMIC / DECLARE_SERIAL / DECLARE_DYNCREATE, etc., and the corresponding IMPLEMENT_XXX macros.
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
|