MENU
Question -

What is the relationship between a class and an object? Illustrate with a suitable example. 



Answer -

A class is a collection of objects. Each object represents the behaviour and functions, which the class members can performs. In other words, an object is an instance of a class.    [1]
For Example:
A Class Box will have characteristics as length, breadth and height:

class Box
 { int length, breadth, height; 
void Display (int length, int breadth, int height) 
{cout<
 };
 void main()
 {Box a=new Box();
 a. Display(10,20,30);
 // a is the object of class Box [1]
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×