#include using namespace std; #include class Rettangolo { double * x, * y; public: Rettangolo (double, double); //costruttore; ~Rettangolo (); double area () {return (*x * *y);} // }; Rettangolo:: Rettangolo (double a, double b){ x= new double; y= new double; *x = a; *y = b; } Rettangolo :: ~Rettangolo () { // necessario per liberare la memoria allocata dinamicamente. delete x; delete y; cout << " x e y deletati" << endl; } int main () { // Rettangolo ret1; // se scommento, ho errore!! Rettangolo ret1(8.0, 10.0); //qui viene usato il costruttore dichiarato. OK! cout << "area (costruttore di default) = " << ret1.area() << endl; return (0); }