Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Rectangle
- {
- public:
- void setData();
- void getData();
- double diag();
- private:
- int a, b;
- int square;
- };
- double Rectangle::diag()
- {
- return sqrt(a*a + b*b);
- }
- void Rectangle::setData()
- {
- cout << "Select the options of your rectangle " << endl;
- cin >> a >> b;
- }
- void Rectangle::getData()
- {
- cout << "Square of your rectangle is " << a*b << endl;
- cout << "Diagonal of your rectangle is " << sqrt(a*a + b*b) << endl;
- }
- int main()
- {
- Rectangle ABCD;
- ABCD.setData();
- ABCD.getData();
- cout << "Diagonal= " << ABCD.diag() << endl;
- system("pause");
- }
- /*int main()
- {
- Rectangle ABCD;
- Rectangle* MNLK;
- ABCD.setData();
- ABCD.getData();
- MNLK = new Rectangle;
- MNLK -> setData();
- MNLK->getData();
- cin.get();
- cin.get();
- return 0;
- }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement