Container Class
C++ permits to declaring an object of a class as a member of another class. Whenever an object of a class is declared as a member of another class, if is known as a container class. A few of the examples for container classes are arrays, linked lists, queues and stacks.
The common syntax for the declaration of container class is, Class user_defined_name_l
{
................
................
................
};
class user_defined_name_2
{
.................
..................
};
class user_defined_name_n
{
.................
..................
};
class derived_class
{
user-defined-name-1 obj1;
user_defined_name_2 obj2;
................
................
user_defined_name_n objn;
};
For instance, the given program segment describes how to declare the container class.
Class basic_info
{
private:
char name[20];
public:
void getdata();
//end of class definition
};
class academic_fit
{
private:
int rank;
public:
void getdata();
}; // end of class definition
class financial_assit
{
private:
basic_info bdata;
academic_fit acd;
float amount;
public:
void getdata();
void display();
}; //end of class definition
void main()
{
financial_assit objf;
....................
}