다음을 통해 공유


vector::clear

벡터의 요소를 지웁니다.

void clear( );

예제

// vector_clear.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
using namespace std;
int main( )
{
vector <int> vec;

    vec.push_back(10);
    vec.push_back(20);
    vec.push_back(30);

    cout << "The size of vec is " << vec.size() << endl;
    cout << "The capacity of vec is " << vec.capacity() << endl;
    vec.clear();
    cout << "The size of vec after clearing is " << vec.size() << endl;
    cout << "The capacity of vec after clearing is " << vec.capacity() << endl;}
  

요구 사항

헤더: <vector>

네임스페이스: std

참고 항목

참조

vector 클래스

표준 템플릿 라이브러리