Professional Documents
Culture Documents
Zainlab 3 P 1
Zainlab 3 P 1
#ifndef _Tree_H
#define _Tree_H
class Tree {
private :
unsigned int height;
public:
Tree() : height(0){
cout << "A tree of zero length has been created." << endl;
}
Tree (unsigned int h) : height(h){
cout << "A tree has been created." << endl;
}
~Tree (){
cout << "Tree has been destroyed." << endl;
}
void grow(int meter){
height +=meter;
}
void printsize(){
cout << "The Height of Tree = " << height << " m" << endl;
}
void create_Tree(); //Declaration
};
#endif
#include "Tree.h"
void Tree::create_Tree(){
Tree ct1;
ct1.grow(6);
ct1.printsize();
#include "Tree.h"
int main(){
create_Tree();
create_Tree();