Odpowiedź :
#include <iostream>
#include <cmath>
using namespace std;
class Rect {
private:
double width;
double height;
public:
Rect(double w, double h) {
width = w;
height = h;
}
double getA() {
return width;
}
double getB() {
return height;
}
double getDiagonal() {
return sqrt(pow(width,2) + pow(height,2));
}
double getArea() {
return height*width;
}
};
int main()
{
Rect r = Rect(3,4);
cout << r.getDiagonal() << " (przekatna)" << endl;
cout << r.getArea() << " (pole)" << endl;
cout << r.getA() << " (szerokosc)" << endl;
cout << r.getB() << " (wysokosc)" << endl;
return 0;
}