Computer >> 컴퓨터 >  >> 프로그램 작성 >> C++

C++의 컨테이너

<시간/>

이 자습서에서는 C++에서 컨테이너를 이해하는 프로그램에 대해 설명합니다.

특정 클래스에 다른 클래스가 포함된 경우 매개변수를 컨테이너선이라고 합니다. 내부 클래스를 포함 클래스라고 하고, 내부 클래스를 컨테이너 클래스라고 합니다.

#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;
}

출력

Hello from first class
Hello from second class