Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream>

using namespace std;

#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();

You might also like