Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class seed {
- int _grow;
- public:
- seed() {
- _grow = 0;
- }
- ~seed() {
- _grow = 0;
- }
- void grow() {
- cout << "seed" << endl;
- _grow++;
- }
- bool fresh() {
- if (_grow < 5) {
- return true;
- }
- else return false;
- }
- void seed_print() {
- cout << "seed" << endl;
- cout << _grow << endl;
- cout << fresh() << endl;
- }
- };
- class plant :public seed {
- int grow_plant, oxygen;
- public:
- plant() {
- grow_plant = 0;
- oxygen = 0;
- }
- ~plant() {
- grow_plant = 0;
- oxygen = 0;
- }
- void grow() {
- cout << "plant" << endl;
- grow_plant++;
- }
- void print() {
- cout << "plant" << endl;
- cout << grow_plant << " " << oxygen << endl;
- }
- void plant_oxygen() {
- oxygen = grow_plant * 2;
- }
- };
- int main() {
- plant P;
- P.print();
- P.grow();
- P.grow();
- P.grow();
- P.grow();
- P.grow();
- P.plant_oxygen();
- P.print();
- P.seed_print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement