Advertisement
Hakuhun

C++ Pont

May 29th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 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(){};
  9.     Pont(int nX, int nY): y(nY),x(nX){};
  10.     void kiir(){
  11.         cout << "x: " << this->x << " y:" << this->y<<"\n";
  12.         cout << "\n";
  13.     }
  14.  
  15. };
  16. int main()
  17. {
  18.     Pont p1(2,3);
  19.     Pont p2(2,3);
  20.     Pont p3(2,3);
  21.     p1.kiir();
  22.  
  23.     Pont pontok[3];
  24.     pontok[0] =Pont(12,13);
  25.     pontok[1] =Pont(14,15);
  26.     pontok[2] =Pont(16,16);
  27.  
  28.     for(int i= 0; i<3; i++){
  29.         pontok[i].kiir();
  30.     }
  31.  
  32.     Pont* ppontok[3];
  33.     ppontok[0] = new Pont(12,13);
  34.     ppontok[1] = new Pont(14,15);
  35.     ppontok[2] = new Pont(16,16);
  36.  
  37.     for(int i= 0; i<3; i++){
  38.         ppontok[i]->kiir();
  39.     }
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement