C
Claudius
Hello,
in the following example, is it correct that the compiler sets the
'this'-pointer to type (const A *) in both calls of the copy-
constructor? (I compiled it with g++-4.3.4)
I had expected (A *).
class A {
public:
A( A & a ) {
int i = 2;
}
A() {}
int i;
};
int main( void ) {
A a;
A b( a ); //this = const A *, ???
const A c( b ); //this = const A *, ok
return 1;
}
So it is not possible to recognize within the copy constructor whether
a const object is to be created or not.
in the following example, is it correct that the compiler sets the
'this'-pointer to type (const A *) in both calls of the copy-
constructor? (I compiled it with g++-4.3.4)
I had expected (A *).
class A {
public:
A( A & a ) {
int i = 2;
}
A() {}
int i;
};
int main( void ) {
A a;
A b( a ); //this = const A *, ???
const A c( b ); //this = const A *, ok
return 1;
}
So it is not possible to recognize within the copy constructor whether
a const object is to be created or not.