Advertisement
Hakuhun

C++ KorbenPont

May 29th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class Pont{
  5. private:
  6.     int x,y;
  7. public:
  8.     Pont(int nX, int nY): y(nY),x(nX){};
  9.     void kiir(){
  10.         cout << "x: " << this->x << " y:" << this->y<<"\n";
  11.         cout << "\n";
  12.     }
  13.     int getX(){return x;}
  14.     int getY(){return y;}
  15.     void setX(int nX){this->x = nX;}
  16.     void setY(int nY){this->y = nY;}
  17. };
  18.  
  19. class Kor{
  20. private:
  21.     int r;
  22.     string tipus;
  23.     Pont p;
  24. public:
  25.     Kor(int nR, int x, int y): p(x,y){
  26.         r=nR;
  27.     };
  28.     void kiir(){
  29.         cout <<"Konstruktor: " << tipus;
  30.         cout << "sugar: " << r;
  31.         cout << "x koordinata: " << p.getX() <<" y koordinataja: " << p.getY();
  32.     }
  33. };
  34. int main()
  35. {
  36.     Kor k(1,2,3);
  37.     k.kiir();
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement