On Dec 16, 11:52 am, George2 <george4acade...@yahoo.comwrote:
Hello everyone,
I am confused what is the type of *this? Type of reference to instance
or type of instance?
When you say type of reference - reference just an alias for an object
- so you can understand it to be the same as type of instance/object.
Looks like both code can compile, no warning messages. Any ideas?
-
class A{
-
A& foo1()
-
{
-
return *this;
-
}
-
A foo2()
-
{
-
return *this;
-
}};
-
Both compile because in one you return a reference to the object (no
copy of *this involved) and in the second case you are returning by
value. That is the difference. The type of *this is same as A.