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

51_vector

by chojju 2018. 5. 9.
반응형

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


//data class
class Member
{
 string name;
 int age;
public:
 Member(string _name, int _age)
  :name(_name), age(_age)
 {
 }
 void Print() const
 {
  cout << name.c_str() << " / " << age << endl;
 }
};

void fun_Print(vector<int*> vec1)
{
 //현재 저장 개수
 cout << "사이즈 : " << vec1.size() << endl;
 //저장할 수 있는 생성된 공간
 cout << "크기 : " << vec1.capacity() << endl;
 //저장할 수 있는 최대 저장공간
 cout << "max : " << vec1.max_size() << endl;

}

int main()
{
 vector<int*> vec1; // max?
 fun_Print(vec1);

 vec1.push_back(new int(1));
 vec1.push_back(new int(2));
 vec1.push_back(new int(3));
 vec1.push_back(new int(3));
 vec1.push_back(new int(3));
 vec1.push_back(new int(3));
 vec1.push_back(new int(3));
 vec1.push_back(new int(3));
 fun_Print(vec1);

 return 0;
}

반응형

댓글