subclassing and storage in a CList
-
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|
-
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|
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.