PDA

View Full Version : Pointer of an unknown type...



TheNewGuy
17th December 2009, 03:44
Support LHWidget1 and LHWidget2 inherits from QWidget.

Now suppose LHWidget3 gets passed either LHWidget1 or LHWidget2. And a property of LHWIdget3 named ptr gets set to the either widget.

How would I do this? this is what I have tried:



LHWidget1* ptr; // complains when LHWidget2 is passed
LHWidget2* ptr; // complains when LHWidget1 is passed
QWidget* ptr; // complains when either is passed

wysota
17th December 2009, 08:50
Solution 3 is the way to go. If there are complaints from the compiler, you probably forgot to include headers for your widgets.