Consider a class Waldo, that inherits from Foo and Baz, viz.:
class Waldo : public Foo, public Baz {
...
};
When I create a new instance of Waldo:
Waldo *w = new Waldo;
do the Foo and Baz constructors get called? If they are not called by default, is there an easy way IN THE CLASS DECLARATION OR IN THE DECLARATION/DEFINITION of the Waldo constructor to force them to be called?
(It looks like I may be trying to do constructor chaining, and C++ allegedly doesn't do that. I'm not sure.)
What I'm trying to do is "annotate" various class declarations, where the annotations cause (among other things) instances of the annotated class to be linked into lists maintained by the annotation classes. This lets me, for example, walk the list of all objects with Baz-nature, applying a certain operation to them, and not have to worry about whether I remembered to add the instance to the list of objects with Baz-nature, because the constructor did it automagically.
Yes, they are called. Left to right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With