lz 发帖数: 23 | 1 I define the following class A
class A
{
A(const A& a)
{
int size=a.getsize();// line4
}
public:
int getsize();
}
I get the following error in line 4
"can not convert 'this' pointer from const A to A& "
Can you guys tell me the reason?
Thanks! |
r****r 发帖数: 115 | 2 int getsize() const;
【在 lz 的大作中提到】 : I define the following class A : class A : { : A(const A& a) : { : int size=a.getsize();// line4 : } : public: : int getsize(); : }
|
lz 发帖数: 23 | 3 does this mean that (const A&) instance can not call its const function?
【在 r****r 的大作中提到】 : int getsize() const;
|
t****t 发帖数: 6806 | 4 this means a const object can't be used to call non-const member function.
doh!
【在 lz 的大作中提到】 : does this mean that (const A&) instance can not call its const function?
|
e*a 发帖数: 32 | 5 牛
【在 t****t 的大作中提到】 : this means a const object can't be used to call non-const member function. : doh!
|