Advertisement
darkjessy94

aggregazione semplice

Sep 7th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. class Motore
  5. {
  6. public:
  7. Motore(int nPistoniI,int cilindrataI)
  8. {
  9. nPistoni=nPistoniI;
  10. cilindrata=cilindrataI;
  11. }
  12. ~Motore(){}
  13. private:
  14. int nPistoni;
  15. int cilindrata;
  16. };
  17.  
  18. class Veicolo
  19. {
  20. public:
  21. Veicolo(string targaI,string nTelaioI,Motore *motoreI)
  22. {
  23. targa=targaI;
  24. nTelaio=nTelaioI;
  25. motore=motoreI;
  26. }
  27. ~Veicolo()
  28. {
  29. delete motore;
  30. }
  31. private:
  32. string targa;
  33. string nTelaio;
  34. Motore *motore;
  35. };
  36.  
  37. int main()
  38. {
  39. Motore a(2,10);
  40. Motore *ptr=&a;
  41. Veicolo auto1("1234","boh",ptr);
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement