Hey
I love this website. The explanations here are terrific.
But I miss something.
I have to learn about stl. I need to use lists and vectors in my homework, and I have no idea on where to find enough info about if here. Under "Reference" there's no much explained, it's like I'm expected to know the syntax on my own.
Is it included in the tutorial, and I just missed it? Where please?
Thanks!
#include <vector>
#include <string>
#include <iostream>
usingnamespace std;
int main()
{
// you can choose any type you wish to use for example
vector<int> numbers;
// insert items at the end
numbers.push_back(1);
numbers.push_back(2);
numbers.push_back(3);
// display contents
for (auto i: numbers)
{
cout << i << endl;
}
// clear vector
numbers.clear();
cout << "size of vector" << numbers.size() << endl;
// insert items at the end
vector<string> names;
names.push_back("joe");
names.push_back("jack");
names.push_back("john");
for (auto i: names)
{
cout << i << endl;
}
int x;
cin >> x;
return 0;
}
Thank you :)
Rafael11, I really appreciate the fact that you wrote a code for me.
JLBorges, thank you for the answer, and for your time.
You helped me a lot, thanks!