![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Containership in C++
In this tutorial, we will be discussing a program to understand containership in C++.
The parameter if a certain class contains another class is called as containership. The inside class is called contained class, while the class in which it is present is called container class.
Example
#include <iostream> using namespace std; class first { public: first(){ cout << "Hello from first class\n"; } }; //container class class second { first f; public: //constructor second(){ cout << "Hello from second class\n"; } }; int main(){ second s; return 0; }
Output
Hello from first class Hello from second class
Advertisements