How do I feel that the compiler is lazy !!!, Compiler suspect
Not necessarily true. Learning!
Struct BB
{
Void (){
Cout <"bb's a () \ n ";
}
};
Struct B1: public BB
{
};
Struct B2: public BB
{
};
Struct CC: virtual public B1, public B2
{
CC ()
{
A (); // call function a. The compilation is not complete. You need to call B1: a (); B2: a (); BB: ();
}
};
In the above Code, calling the () function in the structure of struct CC produces the so-called ambiguity. Okay, that's all. In this example, if the compiler is smart enough, it shouldn't have been necessary. Because this function does not have any "real inheritance" problem, B1 and B2 do not overwrite and define the () function. If it is overwritten, a qualifier must be added for the call. Otherwise, it will produce ambiguity. I can understand this. But in this example, if the compiler allows it to be compiled successfully, is there any ambiguity? Will call errors occur? I don't think so. So let me tell you a bit about it. The compiler is suspected of being lazy. Today's programming is moving towards a more streamlined direction, and useless syntax restrictions will only cause trouble. Well, in the past, there was almost no need to inherit more. I always thought that in this case, directly calling a () would not be a problem. Now I am going to raise my knowledge. The above are rough comments. Sorry for not speaking well!