S
siddhu
Dear Experts,
I have a question.
I wrote the following code
class A
{
public:
void g(){}
};
A f()
{
A a;
return a;
}
int main(int argc, char *argv[])
{
f().g();
return 0;
}
Here f() is temporary on which g() is called which is a non-const
member function of A.
So my doubt is, as we know temporary is always const ,so how it can
call a non-const member function?
Code above is getting compiled.
Thanks in advance,
Siddhu
I have a question.
I wrote the following code
class A
{
public:
void g(){}
};
A f()
{
A a;
return a;
}
int main(int argc, char *argv[])
{
f().g();
return 0;
}
Here f() is temporary on which g() is called which is a non-const
member function of A.
So my doubt is, as we know temporary is always const ,so how it can
call a non-const member function?
Code above is getting compiled.
Thanks in advance,
Siddhu