You have an exercise in the C ++ workbook that asks you to create a function that returns an object by preventing memory leakage. I did so but I'm not sure if it really works:
class Point1{
public : int x;
public : int y;
Point1(int x, int y );
~Point1();
};
Point1::Point1( int x1, int y1 ){
this->x=x1;
y=y1;
std::cout <<"oioi"<<std::endl ;
}
Point1::~Point1(){
std::cout <<"destruu"<<std::endl ;
}
Point1 * retorno(){
Point1* C = new Point1(1,4);
cout<< endl;
return C;
}
int main() {
Point1*C=retorno();
cout << C ;
cout<< endl;
cout<< endl;
cout<< C->x;
return 0;
}