F
fourfires.d
Dear All,
I am new to c++ and when write below code that try to call copy
constructor
in "=" operator overloading, it can not compile. Can anyone point out
for
me the reason? thanks !!
class AA
{
public:
AA( AA & obj)
{
}
AA & operator=( AA & obj)
{
AA(obj);
return *this;
}
};
int main()
{
return 0;
}
pp.cc: In method `class AA & AA:
perator =(AA &)':
pp.cc:11: declaration of `obj' shadows a parameter
pp.cc:11: no matching function for call to `AA::AA ()'
pp.cc:6: candidates are: AA::AA(AA &)
I am new to c++ and when write below code that try to call copy
constructor
in "=" operator overloading, it can not compile. Can anyone point out
for
me the reason? thanks !!
class AA
{
public:
AA( AA & obj)
{
}
AA & operator=( AA & obj)
{
AA(obj);
return *this;
}
};
int main()
{
return 0;
}
pp.cc: In method `class AA & AA:
pp.cc:11: declaration of `obj' shadows a parameter
pp.cc:11: no matching function for call to `AA::AA ()'
pp.cc:6: candidates are: AA::AA(AA &)