Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
45 views

Object Oriented Programming Lab 03 Topic Covered: Constructor and Destructor

The document discusses an object oriented programming lab assignment on constructors and destructors. It involves creating two classes - a Tree class and an Employee class. For the Tree class, it requires implementing a no argument constructor, one argument constructor, destructor, grow(), printsize(), and Create_Tree() functions. For the Employee class, it requires implementing no argument constructor, two argument constructor, destructor, get(), and show() functions. The output of running the program with these classes is also shown.

Uploaded by

Lovely Jutt
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

Object Oriented Programming Lab 03 Topic Covered: Constructor and Destructor

The document discusses an object oriented programming lab assignment on constructors and destructors. It involves creating two classes - a Tree class and an Employee class. For the Tree class, it requires implementing a no argument constructor, one argument constructor, destructor, grow(), printsize(), and Create_Tree() functions. For the Employee class, it requires implementing no argument constructor, two argument constructor, destructor, get(), and show() functions. The output of running the program with these classes is also shown.

Uploaded by

Lovely Jutt
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Object Oriented Programming

Lab 03
Topic Covered: Constructor and Destructor

Q1. Make a Tree class.

 It has one attributes


 height as unsigned int
 Make No Argument Constructor to set height equals to the zero.
Also print this message “A tree of zero length has been created”.
 Make One Argument Constructor to set height equals to the
argument value. Also print this message “A tree has been
created”.
 Make a destructor and print “The tree has been destroyed” message
inside it.
 Make void grow(int meters) function to add argument value to the
tree height value.
 Make void printsize() function to print tree height on screen.
 Make void Create_Tree() function outside the class.
 Make One tree object in Create_Tree() function and call
members functions inside it.
 Call Create_Tree() function two times inside main().
Following is the output of program.

Q1. Make an Employee class.

 It has two attributes


 id as unsigned int
 name as a character pointer.
 Make no argument constructor to set
 ID equal to 1
 name equal to NULL
 Make two arguments constructor to set
 ID equal to first argument
 name equal to second argument dynamically .
 Make a destructor and free the dynamic allocated memory.
 Make void get() functions to get ID and name with spaces from
user.
 Make void show() function to display ID and name on screen.
 Make two Employee objects in main() and call these functions to
check their working.

Following is the output of program.

You might also like