Container Class In C++ | Container Class Explained With Real Life Examples
Container Class In C++
What is a container class?
A container class is that class in which you can create an object of any other class and use it like you use it in your main() function.
To understand containers more quickly suppose you have a house and a hotel class. So a house class may have data members like a number of rooms, bedroom_size, bedroom_color. And a hotel class may have the same data member as a house but it may have some more functionality like checkin_time, checkout_time, etc.
So in this case you can create a hotel as a class container so you can use house data members inside that also.
Here is an example of how you can create a container class in C++ -
Comments
Post a Comment