Vectors and Lists in C ++

0

I am learning C ++ and I have doubts about the use of lists. I'm programming with Sublime Text on Linux. The following code gives the compilation problem 'vector' was not declared in this scope .

#include <iostream>
#include <vector>

int main()
{
    vector<int> v;
    v.push_back(10);

    return 0;
}

I have knowledge of C # in which the statements are very intuitive and in C ++ the relationship with the libraries is costing me work. Can you help me with the correct statement? Thanks!

    
asked by wic 10.03.2018 в 17:40
source

2 answers

1

It does not work because vector is declared in the namespace std. You can use

using namespace std;

to be able to use all the elements of the namespace std. By declaring this you would avoid many times the std:: that is used with the elements of the STL.

    
answered by 10.03.2018 / 23:20
source
1

Declare the variable std::vector<int> v instead of how you have declared it.

References

    
answered by 10.03.2018 в 18:16