그냥저냥

[C++] Conatiner Class 본문

공부/이것저것

[C++] Conatiner Class

오양J 2017. 2. 10. 18:39

※ 컨테이너 클래스란?


Container is a class, a data structure, otr an ADT whose instances are collection of other objects.

In other words, they store objects in an organized way that follows specific access rules.


다른 객체의 포인터를 저장하기 위한 용도로 사용하는 클래스를 일컫는다.

Container 클래스의 기능은 객체(객체 포인터)의 저장/삭제 및 참조에 대한 것을 추상화시키는 것이다.


"객체를 저장하는 방식이 바뀐다고 해도, Container 클래스에만 변경이 생긴다. 다른 클래스들은 전혀 바뀔 필요가 없다."


#include <iostream>
using namespace std;

class Data {
	int data;
public:
	Data(int d) {
		data = d;
	}
	void ShowData() {
		cout << data << endl;
	}
};

typedef Data* Element;

class Container {
private:
	Element* arr;
	int length;
	int aIndex;

public:
	Container(int len = 50);
	~Container();
	void Insert(Element data);
	Element Remove(int idx);
	Element GetItem(int idx);
	int GetElemSum() { return aIndex; };
};

Container::Container(int len) :aIndex(0) {
	 
}
Container::~Container() {

}
void Container::Insert(Element data) {

}
Element Container::Remove(int idx) {

}
Element Container::GetItem(int idx) {

}


Comments