what's wrong with my codes?

Discussion in 'C Programming' started by lihewei126, May 21, 2007.

  1. lihewei126

    lihewei126

    Joined:
    May 21, 2007
    Messages:
    1
    I use visual .net C++ to compile my source file,but I got some errors like

    e:\project\test\test3\test3\Source1.cpp(6): error C2143: syntax error : missing ';' before '<'
    e:\project\test\test3\test3\Source1.cpp(5): error C2143: syntax error : missing ';' before '<'
    e:\project\test\test3\test3\Source1.cpp(5): error C2501: 'vector' : missing storage-class or type specifiers
    e:\project\test\test3\test3\Source1.cpp(6): error C2501: 'vector' : missing storage-class or type specifiers
    e:\project\test\test3\test3\Source1.cpp(6): error C2086: 'int vector' : redefinition
    e:\project\test\test3\test3\Source1.cpp(6): error C2039: 'iterator' : is not a member of 'operator``global namespace'''
    e:\project\test\test3\test3\Source1.cpp(10): error C2065: 'first' : undeclared identifier
    e:\project\test\test3\test3\Source1.cpp(10): error C2065: 'v' : undeclared identifier
    e:\project\test\test3\test3\Source1.cpp(10): error C2228: left of '.insert' must have class/struct/union type
    type is ''unknown-type''
    e:\project\test\test3\test3\Source1.cpp(10): error C3861: 'first': identifier not found, even with argument-dependent lookup
    e:\project\test\test3\test3\Source1.cpp(13): error C2228: left of '.end' must have class/struct/union type
    e:\project\test\test3\test3\Source1.cpp(13): error C3861: 'first': identifier not found, even with argument-dependent lookup
    e:\project\test\test3\test3\Source1.cpp(13): error C3861: 'v': identifier not found, even with argument-dependent lookup
    e:\project\test\test3\test3\Source1.cpp(13): fatal error C1903: unable to recover from previous error(s); stopping compilation





    The following are my source codes:

    #include <vector>
    #include <list>
    #include <deque>

    vector<int> v;
    vector<int>::iterator first = v.begin(),
    last = v.end(); // cache end iterator
    void main(void)
    {
    first = v.insert(first, 42);

    // safer: recalculate end on each trip whenever the loop adds/erases elements
    while (first != v.end()) {
    // do some processing
    first = v.insert(first, 42); // insert new value
    ++first; // advance first just past the element we added
    }
    }

    What's wrong with my codes?
    Last edited: May 21, 2007
    lihewei126, May 21, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg  --
    Replies:
    4
    Views:
    2,156
  2. DaVinci
    Replies:
    1
    Views:
    564
    Piotr Kobzda
    Oct 5, 2006
  3. gj_williams2000@yahoo.co.uk

    Virtual Key Codes, Scan Codes and ASCII Codes in C

    gj_williams2000@yahoo.co.uk, Aug 19, 2005, in forum: C Programming
    Replies:
    2
    Views:
    2,820
    Malcolm
    Aug 20, 2005
  4. chenboston@gmail.com
    Replies:
    2
    Views:
    585
    chenboston@gmail.com
    Mar 16, 2006
  5. Allen
    Replies:
    1
    Views:
    651
    Mark Rae [MVP]
    Dec 3, 2007
Loading...

Share This Page