Advertisement
Guest User

reku

a guest
May 25th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. //
  2. // main.cpp
  3. // osztalyosfeladat
  4. //
  5. // Created by Smith Mary on 2016. 05. 25..
  6. // Copyright Β© 2016. Smith Mary. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <vector>
  11.  
  12. class Contact{
  13. private:
  14. std::string nev;
  15. public:
  16. Contact(std::string vki);
  17. virtual void print(std::ostream& os){
  18. os<<nev;
  19. }
  20. virtual ~Contact(){}
  21.  
  22. };
  23. Contact::Contact(std::string vki){nev=vki;}
  24.  
  25. class Partner: public Contact{
  26. private:
  27. double adokulcs;
  28. public:
  29. Partner(std::string nev, double a);
  30. void print(std::ostream& os){os<<adokulcs; }
  31. };
  32.  
  33. Partner::Partner(std::string nev, double a): Contact(nev), adokulcs(a){}
  34.  
  35. class Relative: public Contact{
  36. private:
  37. int fok;
  38. public:
  39. Relative(std::string nev, int f);
  40. void print(std::ostream& os){os<<fok; }
  41.  
  42.  
  43. };
  44.  
  45. Relative::Relative(std::string nev, int f): Contact(nev), fok(f){}
  46.  
  47. class Bunny: public Partner, public Relative{
  48. public:
  49. void print(std::ostream& os){Partner::print(os); Relative::print(os); }
  50. };
  51.  
  52. class Engine{
  53. private:
  54. std::vector<Contact*> adatok;
  55.  
  56. public:
  57. Engine();
  58. void accept(Contact* valaki){}
  59. void list(std::ostream &os){for(int i=0;i<adatok.size();i++){adatok[i]->print(os);}}
  60. ~Engine(){for(int i=0;i<adatok.size();i++){delete adatok[i];}}
  61. };
  62.  
  63. Engine::Engine(){}
  64.  
  65.  
  66. int main() {
  67. Engine m;
  68. m.accept(new Partner("Reka",10.6));
  69. m.accept(new Relative("Vki",5));
  70. m.accept(new Relative("Masodik",2));
  71.  
  72. m.list(std::cout);
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement