"Danny" <da******@kingkong.me.berkeley.edu> wrote in message
news:d4***********@agate.berkeley.edu...
struct B: public A
{
int & b
B(int & a) : A(a), b(a){}
};
Is A(a), b(a) calling the constructor
A(a) invokes a constructor, it doesn't "call" it.
I have never seen this syntax.
Would this be equivilent to
struct B: public A
{
int & b
B(int & a) : A(a), b(a){
super.A(a)
b=a
}
};
Thanks,
danny
Victor is right, you are missing the semi-colons to end the statements and
super isn't part of C++. However, the code you supplied is close to the Java
equivalent of a C++ class except you would be stating "super(a);" and Java
can't pass_by_reference. Since Java can only inherit from 1 base class,
super designates that base class (A).
No such restriction exists in C++. Any number of parent classes and
interfaces(pure-virtual) can be derived from.