The joy of CObArray

Hiya,

I've got a dialog based program using MFC which needs to pass an array of instances of a class inherited from CObject.  I'm currently using CObArray which is quite happy to take the class but it won't give it back...

Any ideas, I'm floundering again...

Mike


Answer this question

The joy of CObArray

  • BenKC

    You should consider using the DYNAMIC_DOWNCAST macro to that you know that the downcast cast is safe.  This MFC macro works on CObject derivitives and is similar in functionality as the C++ dynamic_cast<> operator: both return NULL (0) if the object being downcasted is not an instance of the derived class.

  • Sander_G

    What is your problem of getting it back.

    Probably you have to cast its type!

    Maybe its easier to use
    template< class BASE_CLASS, class TYPE > class CTypedPtrArray : public BASE_CLASS


  • Haiku

    You were right... casting was the solution...
    Stupidity corrected... until the next time...

    Many Thanks Martin

    Mike Woods


  • The joy of CObArray