Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // osztalyosfeladat
- //
- // Created by Smith Mary on 2016. 05. 25..
- // Copyright Β© 2016. Smith Mary. All rights reserved.
- //
- #include <iostream>
- #include <vector>
- class Contact{
- private:
- std::string nev;
- public:
- Contact(std::string vki);
- virtual void print(std::ostream& os){
- os<<nev;
- }
- virtual ~Contact(){}
- };
- Contact::Contact(std::string vki){nev=vki;}
- class Partner: public Contact{
- private:
- double adokulcs;
- public:
- Partner(std::string nev, double a);
- void print(std::ostream& os){os<<adokulcs; }
- };
- Partner::Partner(std::string nev, double a): Contact(nev), adokulcs(a){}
- class Relative: public Contact{
- private:
- int fok;
- public:
- Relative(std::string nev, int f);
- void print(std::ostream& os){os<<fok; }
- };
- Relative::Relative(std::string nev, int f): Contact(nev), fok(f){}
- class Bunny: public Partner, public Relative{
- public:
- void print(std::ostream& os){Partner::print(os); Relative::print(os); }
- };
- class Engine{
- private:
- std::vector<Contact*> adatok;
- public:
- Engine();
- void accept(Contact* valaki){}
- void list(std::ostream &os){for(int i=0;i<adatok.size();i++){adatok[i]->print(os);}}
- ~Engine(){for(int i=0;i<adatok.size();i++){delete adatok[i];}}
- };
- Engine::Engine(){}
- int main() {
- Engine m;
- m.accept(new Partner("Reka",10.6));
- m.accept(new Relative("Vki",5));
- m.accept(new Relative("Masodik",2));
- m.list(std::cout);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement