CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    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


  2. #2
    Join Date
    Apr 1999
    Posts
    383

    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
  •  





Click Here to Expand Forum to Full Width

Featured