Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- class Zwierze{
- public:
- virtual Zwierze* copy() const;
- };
- class Kot: public Zwierze{
- public:
- Zwierze* copy() const{
- return new Kot(*this);
- }
- };
- class Pies: public Zwierze{
- public:
- Zwierze* copy() const{
- return new Pies(*this);
- }
- };
- class Kura: public Zwierze{
- public:
- Zwierze* copy() const{
- return new Kura(*this);
- }
- };
- class Zagroda: std::vector<Zwierze*>{
- public:
- ~Zagroda();
- Zagroda(const Zagroda&);
- Zagroda& operator=(const Zagroda&);
- };
- Zagroda::~Zagroda(){
- this->clear();
- }
- Zagroda::Zagroda(const Zagroda& copy) {
- Zagroda::const_iterator it;
- for(it=copy.begin(); it!=copy.end(); it++){
- this->push_back((*it)->copy());
- }
- }
- Zagroda& Zagroda::operator=(const Zagroda& copy) {
- this->clear();
- Zagroda::const_iterator it;
- for(it=copy.begin(); it!=copy.end(); it++){
- this->push_back((*it)->copy());
- }
- }
- int main(){
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement