dobrizaj

class round

Oct 21st, 2014
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include "stdafx.h"
  2.  
  3. #include <conio.h>
  4. #include <iostream>
  5.  
  6. class Round
  7. {
  8. public:
  9.     Round();
  10.     ~Round();
  11.  
  12.     float GetArea();
  13.     float GetLength();
  14.    
  15.     void SetRadius(float r);
  16.     void SetCenter(float newx, float newy);
  17. private:
  18.     float radius;
  19.     float x, y;
  20. };
  21.  
  22. Round::Round()
  23. {
  24.     std::cout << "Enter x: ";
  25.     std::cin >> x;
  26.  
  27.     std::cout << "Enter y: ";
  28.     std::cin >> y;
  29.  
  30.     std::cout << "Enter raduis: ";
  31.     std::cin >> radius;
  32. }
  33.  
  34. Round::~Round()
  35. {
  36.  
  37. }
  38.  
  39. float Round::GetArea()
  40. {
  41.     return 3.14 * pow(radius, 2.0);
  42. }
  43.  
  44. float Round::GetLength()
  45. {
  46.     return 2.0 * 3.14 * radius;
  47. }
  48.  
  49. void Round::SetRadius(float r)
  50. {
  51.     radius = r;
  52. }
  53.  
  54. void Round::SetCenter(float newx, float newy)
  55. {
  56.     x = newx;
  57.     y = newy;
  58. }
  59.  
  60. int _tmain(int argc, _TCHAR* argv[])
  61. {
  62.     Round *r = new Round;
  63.  
  64.     std::cout << r->GetLength() << std::endl;
  65.     std::cout << sizeof(r) << std::endl;
  66.     std::cout << sizeof(*r) << std::endl;
  67.    
  68.     delete r;
  69.  
  70.     std::cout << "Press any key to exit" << std::endl;
  71.     _getch();
  72.     return 0;
  73. }
Advertisement
Add Comment
Please, Sign In to add comment