obiektowe1
unknown
c_cpp
3 years ago
807 B
7
Indexable
#include <iostream> using namespace std; class Rectangle { int width; int height; public: void set_values(int x, int y) { width = x; height = y; } int area() { return width * height; } void print_content() { cout << width << endl; cout << height << endl; } int calc_diagonal() { return sqrt(pow(width,2) + pow(height,2)); } }; int main() { Rectangle prostokat1; Rectangle prostokat2; prostokat1.set_values(4,5); prostokat1.print_content(); prostokat2.set_values(10, 19); prostokat2.print_content(); cout << endl << prostokat1.calc_diagonal(); cout << endl << prostokat2.calc_diagonal(); return 0; }
Editor is loading...