S
Subhransu Sekhar Sahoo
Hu folks,
Can anyone explain why is the out put of the following program is
"from CB fun".
#include <iostream>
using namespace std;
class CA{
public:
void fun() {cout<<"from CA fun"<<endl;}
};
class CB
{
CA *p;
public:
CB(CA* tp=new CA)(tp)
{
}
CA * operator->()
{
int x = 10;
return p;
}
void fun() {cout<<"from CB fun"<<endl;}
};
void main()
{
CB *obj = new CB;
obj->fun();
delete obj;
}
Thnking in advance,
Subhransu S
Can anyone explain why is the out put of the following program is
"from CB fun".
#include <iostream>
using namespace std;
class CA{
public:
void fun() {cout<<"from CA fun"<<endl;}
};
class CB
{
CA *p;
public:
CB(CA* tp=new CA)(tp)
{
}
CA * operator->()
{
int x = 10;
return p;
}
void fun() {cout<<"from CB fun"<<endl;}
};
void main()
{
CB *obj = new CB;
obj->fun();
delete obj;
}
Thnking in advance,
Subhransu S