• Related Questions & Answers

Containership in C++

C++Server Side ProgrammingProgramming

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.


 Live Demo

#include <iostream>
using namespace std;
class first {
      cout << "Hello from first class\n";
//container class
class second {
   first f;
      cout << "Hello from second class\n";
int main(){
   second s;
   return 0;


Hello from first class
Hello from second class
Published on 12-Mar-2020 06:07:41