473,395 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
3 50410
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
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

    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 thread has been closed and replies have been disabled. Please start a new discussion.

    Similar topics

    2
    by: Henrik S. Hansen | last post by:
    I'm new to C++, and cannot figure out why this won't compile: std::map<std::string, int> tst; tst = 1; int main() { /*...*/ } It gives me: error: ISO C++ forbids declaration of `tst' with...
    5
    by: j0mbolar | last post by:
    operator = (const char *string) { if(m_string) { free(m_string); m_string = 0; } if(string) { m_string = strdup(string); } }
    4
    by: Juhan Voolaid | last post by:
    Hi I need help here. When i compile my program, i get this error: $ make g++ -c -Wall inf2_functions.cpp -o inf2_functions.o inf2_classes.h:6: error: ISO C++ forbids declaration of ‘vector’...
    1
    by: eric | last post by:
    hello i'm trying to implement some functionality whereby an algorithm in a base template class relies on a function pointer supplied by a derived template class. the types are only specified by...
    7
    by: Florian Haag | last post by:
    Hello, I'm trying to compile a programme which compiles fine under Linux; I'm trying it with MinGW G++ 3.4.2: Component.h: #ifndef COMPONENT_H_ #define COMPONENT_H_
    6
    by: mkborregaard | last post by:
    Hi, I am getting an error message from MinGW that I just cannot figure what causes. The error message is: "Line 16: ISO C++ forbids declaration of 'AreaMap' with no type" My code is: #ifndef...
    8
    by: aneuryzma | last post by:
    Hello, I'm merging an OpenCV app with an Ogre3d app. I'm on a mac, I'm using xCode. When I add #include "openCVApp.h" I got the following error:
    6
    by: samsneelam | last post by:
    Hi.. This is samuel, while doing a program, i encountered this problem.. Let me give you clarity regarding my prob.. I am having two files .. one is mpcplib.h it contains the follwing...
    10
    by: tvnaidu | last post by:
    I am using Three pthread functions below, I got ISO error, then I declared int variable called val123, then I assigned, but still I am getting error, any idea?. also I included pthread.h. compiling...
    0
    by: Charles Arthur | last post by:
    How do i turn on java script on a villaon, callus and itel keypad mobile phone
    0
    by: ryjfgjl | last post by:
    If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
    0
    by: emmanuelkatto | last post by:
    Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
    0
    BarryA
    by: BarryA | last post by:
    What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
    1
    by: nemocccc | last post by:
    hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
    1
    by: Sonnysonu | last post by:
    This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
    0
    by: Hystou | last post by:
    There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
    0
    jinu1996
    by: jinu1996 | last post by:
    In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
    0
    tracyyun
    by: tracyyun | last post by:
    Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

    By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

    To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.