ISO C++ forbids declaration of 'vector' with no type

G

gamehack

Hi all,

Here's the error which I'm getting when trying to compile some code:

Code:
boxmanager.h:16: error: ISO C++ forbids declaration of 'vector'
with no type
boxmanager.h:16: error: expected ';' before '<' token
boxmanager.h:17: error: ISO C++ forbids declaration of 'vector'
with no type
boxmanager.h:17: error: expected ';' before '<' token

And the code is:
Code:
private:
		vector<Box> boxes; // line 16
		vector<int> chosenmoney; // line 17

I'm doing some silly mistake but cannot see what it is. Thanks.
 
T

Thomas Tutone

gamehack said:
Hi all,

Here's the error which I'm getting when trying to compile some code:

Code:
boxmanager.h:16: error: ISO C++ forbids declaration of 'vector'
with no type
boxmanager.h:16: error: expected ';' before '<' token
boxmanager.h:17: error: ISO C++ forbids declaration of 'vector'
with no type
boxmanager.h:17: error: expected ';' before '<' token

And the code is:
Code:
private:
		vector<Box> boxes; // line 16
		vector<int> chosenmoney; // line 17

I'm doing some silly mistake but cannot see what it is. Thanks.

Three errors that I see.

1. Failure to post complete, compilable code. See Sec. 5.8 of the
FAQ.
2. Failure to include the proper header (#include <vector>) - unless,
of course, it's in the code you forgot to post.
3. Failure to qualify your reference to vector. It's std::vector
(unless you've previously included: using std::vector;

And please don't put "using namespace std;" in the header file (just in
case you were tempted).

Best regards,

Tom
 
V

Victor Bazarov

gamehack said:
Here's the error which I'm getting when trying to compile some code:

Code:
boxmanager.h:16: error: ISO C++ forbids declaration of 'vector'
with no type
boxmanager.h:16: error: expected ';' before '<' token
boxmanager.h:17: error: ISO C++ forbids declaration of 'vector'
with no type
boxmanager.h:17: error: expected ';' before '<' token

And the code is:
Code:
private:
		vector<Box> boxes; // line 16 

		vector<int> chosenmoney; // line 17

I'm doing some silly mistake but cannot see what it is. Thanks.

What book on C++ you're reading that doesn't have proper examples of using
standard 'vector' template?

V
 
G

gamehack

Thomas said:
gamehack wrote: [snip]

Three errors that I see.

1. Failure to post complete, compilable code. See Sec. 5.8 of the
FAQ.
2. Failure to include the proper header (#include <vector>) - unless,
of course, it's in the code you forgot to post.
3. Failure to qualify your reference to vector. It's std::vector
(unless you've previously included: using std::vector;

And please don't put "using namespace std;" in the header file (just in
case you were tempted).

Best regards,

Tom

Solved the problem. Thanks a lot!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top