vector - STL C++

vector<X, A>::size()

Declaration

size_type vector<X,A>::size() const;

Description

This is the size() function for the vector class template.

Header Include

#include <vector>

Example

#include <iostream>
#include <vector>

int main()
{
	using namespace std;

	// Create a vector instance
	vector<int> qV;
	qV.push_back('X');
	qV.push_back('o');
	qV.push_back('a');
	qV.push_back('X');
	qV.push_back('.');
	qV.push_back('n');
	qV.push_back('e');
	qV.push_back('t');

	// Output the size of the vector
	cout << "vector size = " << qV.size() << endl;

	// Keep the window open
	cin.get();
	return 0;
}

Output

vector<X, A>::size() Output
 

© 2007–2025 XoaX.net LLC. All rights reserved.