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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. subclassing and storage in a CList

subclassing and storage in a CList

Scheduled Pinned Locked Moved C / C++ / MFC
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.
  • S Offline
    S Offline
    squizz
    wrote on last edited by
    #1

    Hi ! I wan't to develop a test app to add shapes to a CScrollView on mouse clicks. I created a base class CShape and derived CSquare, CCircle ... classes. each class has a .Draw method. To store objects, I created a class class CShapeList : public CList with a .Draw method that iterates through items and calls .Draw for each object. The problem is that the method invoked is always the base class CShape .Draw HELLLLLP ! X|

    A 1 Reply Last reply
    0
    • S squizz

      Hi ! I wan't to develop a test app to add shapes to a CScrollView on mouse clicks. I created a base class CShape and derived CSquare, CCircle ... classes. each class has a .Draw method. To store objects, I created a class class CShapeList : public CList with a .Draw method that iterates through items and calls .Draw for each object. The problem is that the method invoked is always the base class CShape .Draw HELLLLLP ! X|

      A Offline
      A Offline
      Andrew Peace
      wrote on last edited by
      #2

      You need to make your function virtual. To do this, add the keyword 'virtual' in front of it's declaration in the class's header file. You might wanna read up on this 'cause it's a rather important part of C++ :). -- Andrew.

      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