Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++: Syntax error C2061: Unexpected identifier

What's wrong with this line of code?

bar foo(vector ftw);

It produces

error C2061: syntax error: identifier 'vector'
like image 314
Nick Heiner Avatar asked Jan 02 '26 09:01

Nick Heiner


2 Answers

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

#include <vector>
like image 195
Adrian Grigore Avatar answered Jan 03 '26 23:01

Adrian Grigore


Probably you forgot to include vector and/or import std::vector into the namespace.

Make sure you have:

#include <vector>

Then add:

using std::vector;

or just use:

bar foo(std::vector<odp> ftw);
like image 20
Matthew Flaschen Avatar answered Jan 03 '26 23:01

Matthew Flaschen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!