By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,750 Members | 1,367 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,750 IT Pros & Developers. It's quick & easy.

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

P: n/a
Hi all,

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

Expand|Select|Wrap|Line Numbers
  1. boxmanager.h:16: error: ISO C++ forbids declaration of 'vector'
  2. with no type
  3. boxmanager.h:16: error: expected ';' before '<' token
  4. boxmanager.h:17: error: ISO C++ forbids declaration of 'vector'
  5. with no type
  6. boxmanager.h:17: error: expected ';' before '<' token
  7.  
And the code is:
Expand|Select|Wrap|Line Numbers
  1. private:
  2. vector<Box> boxes; // line 16
  3. vector<int> chosenmoney; // line 17
  4.  
I'm doing some silly mistake but cannot see what it is. Thanks.

Feb 13 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
gamehack wrote:
Hi all,

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

Expand|Select|Wrap|Line Numbers
  1.  boxmanager.h:16: error: ISO C++ forbids declaration of 'vector'
  2.  with no type
  3.  boxmanager.h:16: error: expected ';' before '<' token
  4.  boxmanager.h:17: error: ISO C++ forbids declaration of 'vector'
  5.  with no type
  6.  boxmanager.h:17: error: expected ';' before '<' token
  7.  

And the code is:
Expand|Select|Wrap|Line Numbers
  1.  private:
  2.          vector<Box> boxes; // line 16
  3.          vector<int> chosenmoney; // line 17
  4.  

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

Feb 13 '06 #2

P: n/a
gamehack wrote:
Here's the error which I'm getting when trying to compile some code:

Expand|Select|Wrap|Line Numbers
  1.  boxmanager.h:16: error: ISO C++ forbids declaration of 'vector'
  2.  with no type
  3.  boxmanager.h:16: error: expected ';' before '<' token
  4.  boxmanager.h:17: error: ISO C++ forbids declaration of 'vector'
  5.  with no type
  6.  boxmanager.h:17: error: expected ';' before '<' token
  7.  

And the code is:
Expand|Select|Wrap|Line Numbers
  1.  private:
  2.          vector<Box> boxes; // line 16
  •  
  • Did you forget to #include <vector>?  Did you know that 'vector' template
  • is declared in 'std' namespace?
  •          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
    --
    Please remove capital As from my address when replying by mail
    Feb 13 '06 #3

    P: n/a

    Thomas Tutone wrote:
    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!

    Feb 13 '06 #4

    This discussion thread is closed

    Replies have been disabled for this discussion.