본문 바로가기
01.Bit 단기/C++

47_char 저장 컨테이너

by chojju 2018. 5. 9.
반응형

#include <iostream>
#include <algorithm> //STL 알고리즘 함수
using namespace std;
#include <time.h>

class MyVector  {
 char arr[10];
public:
 char& operator[] (int idx);
};

char& MyVector::operator[] (int idx)
{
 return arr[idx];
}

int main()
{
 MyVector vec;
 for (int i = 0; i < 10; i++)
  vec[i] = i+'a';

 for (int i = 0; i < 10; i++)
  cout << vec[i] << "\t";
 cout << endl;
 
 return 0;
}

 

반응형

'01.Bit 단기 > C++' 카테고리의 다른 글

49_배열 템플릿(overflow, pushback, erase 구현)  (0) 2018.05.09
48_템플릿클래스로 변경  (0) 2018.05.09
46_int 저장 컨테이너  (0) 2018.05.09
45_STL Sort 함수  (0) 2018.05.09
44_STL find 함수  (0) 2018.05.09

댓글