I realize that the following is horrible style, but for the sake of argument, assume I have the following code:
struct parent
{
virtual ~parent() {}
};
struct child : public parent
{
child() {}
virtual ~child() {}
};
struct anotherClass
{
static parent& anyName;
};
child anyName; // create an instance of 'child'
parent& anotherClass::anyName = anyName; // create a parent-class ref to the child object
When I initialize the anotherClass::anyName
reference above with anyName
, which anyName
am I initializing it with? The child-class object, or with itself? (To which entity does the last anyName
in the last line refer? Is it ambiguous?) And where in the C++ spec would something like this be addressed?
(BTW this question has absolutely nothing to do with my other question posted a few minutes earlier.)