fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4.  
  5. class PUNKT{
  6. public:
  7. PUNKT(int px=0, int py=0): x(px),y(py) {++zaehl;}
  8. ~PUNKT() {--zaehl;}
  9. void verschiebe(int dx, int dy);
  10. void ausgabe();
  11. protected:
  12. int x,y;
  13. static int zaehl; // Anzahl der Elemente
  14. };
  15.  
  16. int PUNKT::zaehl=1;
  17.  
  18. void PUNKT::verschiebe(int dx, int dy) {
  19. x=dx;
  20. y=dy;
  21. }
  22.  
  23. void PUNKT::ausgabe() {
  24. std::cout << zaehl << " Punkt " << x << "/" << y << std::endl;
  25. }
  26.  
  27. int main(int count, char **args) {
  28.  
  29. std::vector<PUNKT> test;
  30. test.push_back(PUNKT(2,3));
  31. test.push_back(PUNKT(2,3));
  32. test.push_back(PUNKT(2,3));
  33. test[0].ausgabe();
  34. test.clear();
  35. test[0].ausgabe();
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
-2 Punkt 2/3
-5 Punkt 2/3