Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can I use the DECLARE_DYNAMIC macro for a CList derived class?

Can I use the DECLARE_DYNAMIC macro for a CList derived class?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Charles Liu
    wrote on last edited by
    #1

    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?

    R 1 Reply Last reply
    0
    • C Charles Liu

      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?

      R Offline
      R Offline
      Ryan Binns
      wrote on last edited by
      #2

      Charles Liu wrote: How can I declare it to be dynamic? Yes, but instead of CList<CPoint*,CPoint*&>, you need to use CObject. CList is not DECLARE_DYNAMIC(), so you can't specify it as the base class. Doing this means that you can tell what class the CPointList is, but it will appear to be a direct descendent of CObject, ie. RUNTIME_CLASS(CPointList)->GetBaseClass() will return RUNTIME_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"

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups