S
Skybuck Flying
Hello,
I have a question about the parenthesis (see *) and further consequences of
it in the following example class:
class TSomeClass
{
TSomeOtherClass mSomeOtherClass1(); // *
TSomeOtherClass mSomeOtherClass2;
void SomeRoutine();
};
void TSomeClass::SomeRoutine()
{
mSomeOtherClass1.SomeRoutine(); // does not compile
// compiler error message:
// error: nonstandard form for taking the address of a member function
// error: expression must have class type
mSomeOtherClass1->SomeRoutine(); // does not compile
// error: nonstandard form for taking the address of a member function
// error: expression must have pointer type
mSomeOtherClass2.SomeRoutine(); // compiles just fine.
}
So what is the effect of the parenthesis at // *.
To me it looked as if the default constructor for mSomeOtherClass1 was being
called ?
But perhaps something else is happening which causes the
mSomeOtherClass2.SomeRoutine call to fail to compile ?!
Does mSomeOtherClass2 need to be "constructed" by calling it's constructor
in the default constructor of TSomeClass or is that automatic (so when
parenthesis in the member declaration are left out) ?.
Bye,
Skybuck.
I have a question about the parenthesis (see *) and further consequences of
it in the following example class:
class TSomeClass
{
TSomeOtherClass mSomeOtherClass1(); // *
TSomeOtherClass mSomeOtherClass2;
void SomeRoutine();
};
void TSomeClass::SomeRoutine()
{
mSomeOtherClass1.SomeRoutine(); // does not compile
// compiler error message:
// error: nonstandard form for taking the address of a member function
// error: expression must have class type
mSomeOtherClass1->SomeRoutine(); // does not compile
// error: nonstandard form for taking the address of a member function
// error: expression must have pointer type
mSomeOtherClass2.SomeRoutine(); // compiles just fine.
}
So what is the effect of the parenthesis at // *.
To me it looked as if the default constructor for mSomeOtherClass1 was being
called ?
But perhaps something else is happening which causes the
mSomeOtherClass2.SomeRoutine call to fail to compile ?!
Does mSomeOtherClass2 need to be "constructed" by calling it's constructor
in the default constructor of TSomeClass or is that automatic (so when
parenthesis in the member declaration are left out) ?.
Bye,
Skybuck.