Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. // zwykla klasa
  2. class Klasa
  3. {
  4. int a,b;
  5. }
  6.  
  7. //uzyta kompozycja - przyklad trywialny
  8. class Klasa
  9. {
  10.     int a,b;
  11.     string imie;
  12. }
  13.  
  14. //inny przyklad
  15. class Author // twoja klasa z biblioteki
  16. {
  17.     string imie, nazwisko;
  18. }
  19.  
  20. // i teraz kompozycja
  21. class Book
  22. {
  23.     Author autor_ksiazki; // tutaj tworzysz obiekt swojej klasy <- to jest kompozycja
  24.     string title;
  25. }
  26.  
  27. // w skrocie: wewnatrz tworzonej klasy tworzysz obiekt innej dowolnej klasy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement