What happens when you attempt to compile and run the following code?
#include
using namespace std;
class BaseC
{
public:
int *ptr;
BaseC() { ptr = new int(10);}
BaseC(int i) { ptr = new int(i); }
~BaseC() { delete ptr; }
};
void fun(BaseC x);
int main()
{
BaseC *o = new BaseC(5);
fun(*o);
}
void fun(BaseC x) {
cout << "Hello:"<<*x.ptr;
}
Currently there are no comments in this discussion, be the first to comment!