C ++: syntax error C2061: unexpected identifier

What is wrong with this line of code?

bar foo (vector ftw);

He produces

error C2061: syntax error: identifier 'vector'
+3
source share
5 answers

try std :: vector. Also, make sure that you

#include <vector>
+5
source

You may have forgotten to include the vector and / or import std::vectorinto the namespace.

Make sure you have:

#include <vector>

Then add:

using std::vector;

or just use:

bar foo(std::vector<odp> ftw);
+4
source

std::vector<odp> using std;

0

:

#include <vector>

using namespace std; ?

<vector> std::vector, - .

vector, , std (, , ), using namespace std;

std::vector<myclass>

0

bar, vector odp. , bar, , .

I assume that it should define fooas a function what it vectorcalls the template and that it should define a parameter with a name ftw, but there is nothing in the declaration that is not actually defined to be declared earlier, so that the compiler knows what all the other identifiers mean.

For example, if you define new types as follows, you get a fragment that will compile:

struct bar {};
struct odp {};
template<class T> struct vector {};

bar foo(vector<odp> ftw);
0
source

Source: https://habr.com/ru/post/1749681/


All Articles