I've figured out what the problem was.
The actual class hierarchy was more involved than what was portrayed here (although I could not see at the time how that could be a problem, which is why I didn't include that detail here). What caused the problem was the fact that A was a virtual base for AA (and other classes that also fed into AAAA).
Without that detail, then, what I typed in my first post, and how I initialised things (AAAA's initialiser list tells which of AAA's constructors to use, and the initialiser list in whichever of AAA's constructors is called in turn tells AA which constructor to use, etc.) was in fact correct, as written.
When you have a virtual base class, however, things are different. With the following class structure:
class A{...};
class AA : public virtual A {...};
class AB : public virtual A {...};
class AAA: public AA, public AB {...};
without the virtual keyword, AAA would actually include two distinct copies of A. When virtual is included as shown here, only one common copy is used, and thus C++ needs to ensure that the constructor for A is called once only. The way it does that is by declaring that the most derived class (in this case, AAA) determines which of A's constructors is called, regardless of what is specified in AA or AB.
In my case, AAAA did not specify a constructor for A (I assumed that this would be specified from what I told AA to do). Since there was therefore no A constructor that the compiler was being told to use, it went looking for the default constructor, which of course it couldn't find. Hence, some very confusing error messages (until I finally understood where I had stuffed up).
Experience: Something you invariably acquire immediately after you needed it.
__________________
Maybe you should put some shorts on or something, if you wanna keep fighting evil today.
Last edited by OzOz; 11-30-2007 at 01:53 PM..
|