Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- class Pies
- {
- public:
- std::string imie;
- short wiek;
- Pies(std::string i, short w)
- {
- imie = i;
- wiek = w;
- }
- void szczekaj()
- {
- std::cout << "hau hau" << std::endl;
- }
- ~Pies()
- {}
- };
- class Wlasciciel :public Pies
- {
- public:
- std::string imie;
- Pies szarik;
- void w(std::string i, Pies sz)
- {
- imie = i;
- szarik = sz;
- }
- void zawolajPsa()
- {
- std::cout << "szarik!" << std::endl;
- }
- ~Wlasciciel()
- {}
- };
- int main()
- {
- int wiek = 4;
- Pies* szarik = new Pies("szarik", wiek);
- szarik->szczekaj(); //wypisuje "hau hau"
- Wlasciciel w("Janek", szarik);
- w.zawolajPsa(); //wypisuje "szarik!"
- return 0;
- }
- /*
- Bledy takowe:
- exit status 1
- main.cpp: In function 'int main()':
- main.cpp:51:33: error: no matching function for call to 'Wlasciciel::Wlasciciel(const char [6], Pies*&)'
- Wlasciciel w("Janek", szarik);
- ^
- main.cpp:25:7: note: candidate: 'Wlasciciel::Wlasciciel(const Wlasciciel&)'
- class Wlasciciel :public Pies
- ^~~~~~~~~~
- main.cpp:25:7: note: candidate expects 1 argument, 2 provided
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement