Can I use the DECLARE_DYNAMIC macro for a CList derived class?
-
I got a class derived from CList, as class CPointList : public CList { ... } I want to declare it DYNAMIC, but as i wrote this in .cpp IMPLEMENT_DYNAMIC(CPointList,CList The compiler gave an error: warning C4002: too many actual parameters for macro 'IMPLEMENT_DYNAMIC' How can I declare it to be dynamic?
-
I got a class derived from CList, as class CPointList : public CList { ... } I want to declare it DYNAMIC, but as i wrote this in .cpp IMPLEMENT_DYNAMIC(CPointList,CList The compiler gave an error: warning C4002: too many actual parameters for macro 'IMPLEMENT_DYNAMIC' How can I declare it to be dynamic?
Charles Liu wrote: How can I declare it to be dynamic? Yes, but instead of
CList<CPoint*,CPoint*&>
, you need to useCObject
.CList
is notDECLARE_DYNAMIC()
, so you can't specify it as the base class. Doing this means that you can tell what class theCPointList
is, but it will appear to be a direct descendent ofCObject
, ie.RUNTIME_CLASS(CPointList)->GetBaseClass()
will returnRUNTIME_CLASS(CObject)
. BTW, the reason the compiler tells you it has too many parameters is because the preprocessor doesn't care about C syntax - it just splits the macro at the commas. It does not care (and does not know) that the second comma is inside a template definition, and assumes it to be separating parameters. The only comma is treats differently is one that's inside a string. Ryan Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"