Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class pies
- {
- public:
- string wyswietl()
- {
- return "Pies";
- }
- };
- class kot
- {
- public:
- string wyswielt()
- {
- return "Kot";
- }
- };
- template <typename B,int pojemnosc>
- class buda
- {
- B *wsk[pojemnosc];
- public:
- B *get(int indeks)
- {
- return wsk[indeks];
- }
- B set(B wartosc,int indeks)
- {
- *wsk[indeks]=wartosc;
- }
- };
- int main(int argc, char *argv[])
- {
- kot czesiek;
- pies papito;
- buda<pies,1> psia;
- buda<kot,2> kocia;
- psia.set(papito,1);
- kocia.set(czesiek,1);
- cout<<psia.get(1)->wyswietl()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment