C++ Base class question

Started by
0 comments, last by webjeff 20 years, 1 month ago
Is this possible? I have this: ClassA : BASECLASS { public: void test() { int j = 1; } ; } class BASECLASS { public: int num=1; int runme() { num ++; }; } ///////////////CAN I do this: class someotherclass { public BASECLASS* list; storeclass(BASECLASS* class) { list = class; }; } and do it like this: --> storeclass(&classA); ???????? IS THIS POSSIBLE??? Cause ClassA isn''t BASECLASS but its base class is. How would I do this? Do I need a void* instead?? Thanks Jeff.
Advertisement
Yes, it is possible, that''s the way you define interface classes.

problem may be you can''t call
someotherclass.list->test();

as "someotherclass.list" is of the type "BASECLASS" which hasn''t the "test" function defined.
You had to recast it to BASECLASS, or put "test" into the interface of BASECLASS.
-----The scheduled downtime is omitted cause of technical problems.

This topic is closed to new replies.

Advertisement