Message Board
Message Board > C/C++ > Pointer to class as if it were the base class |
July 16, 2007, 19:55 | |
DTM
Earthling! 821 posts |
Can I use a pointer to a class that inherits from several others as if it were just one of the base classes... LIKE: Code: class Something class AnotherThing : public Something, public WhateverElse Anotherthing anotherthing; Something *something = &anotherthing; something->variable ++; Is this allowed? (Well it seems not because the variable has a wrong value when I access it... Bah) ____________ :o |
# |
July 30, 2007, 18:40 | |
AXR
Ear-Infecting Monkey 36 posts |
Are you trying to make a linked list of classes? Whats the goal in this? ____________ SHALOM, MA NISHMA AcHI!? |
# |
July 30, 2007, 22:30 | |
PEader
お前はもう死んでいる 1486 posts |
you need to cast it to a Something pointer type. Don't you get compiler warnings about it? [edit]Hmm, this post is a bit old. I guess you got it sorted by now. [Edited on July 30, 2007 by PEader] ____________ I see 57,005 people. |
# |
Message Board > C/C++ > Pointer to class as if it were the base class