Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- #include <fstream>
- using namespace std;
- class Tree {
- protected:
- string name;
- unsigned age;
- unsigned branches;
- public:
- friend ifstream & operator>>(ifstream & in, Tree & t) {
- in>>t.name;
- in>>t.age;
- in>>t.branches;
- return in;
- }
- friend ostream & operator<<(ostream & os, const Tree & t) {
- os<<"Name: "<<t.name<<endl;
- os<<"Age: "<<t.age<<endl;
- os<<"Number of branches: "<<t.branches<<endl<<endl;
- return os;
- }
- string get_name()const {return name;}
- unsigned get_branches()const {return branches;}
- };
- class Plod:public Tree {
- private:
- string sort;
- double vrozh;
- public:
- friend ifstream & operator>>(ifstream & in, Plod & p) {
- in>>p.name;
- in>>p.age;
- in>>p.branches;
- in>>p.sort;
- in>>p.vrozh;
- return in;
- }
- friend ostream & operator<<(ostream & os, const Plod & p) {
- os<<"Name: "<<p.name<<endl;
- os<<"Age: "<<p.age<<endl;
- os<<"Number of branches: "<<p.branches<<endl;
- os<<"Sort: "<<p.sort<<endl;
- os<<"Vrozhaynist: "<<p.vrozh<<endl<<endl;
- return os;
- }
- string get_sort()const {return sort;}
- double get_vrozh()const {return vrozh;}
- };
- class Decor:public Tree {
- private:
- double height;
- double pryrist;
- public:
- double get_height()const {return height;}
- double get_pryrist()const {return pryrist;}
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement