c++ initializing a vector - please help.

Discussion in 'General Computer Support' started by chardane, Jul 23, 2010.

  1. chardane

    chardane

    Joined:
    Jul 23, 2010
    Messages:
    1
    can anyone please look at this code and tell me what's wrong?

    #include <iostream>
    #include <vector>

    int a[] = { 1,2,3,4,5,6,7,8,9,10 }; //array of 10

    vector<int> gv(a, a + sizeof(a)/sizeof(*a));


    int main {

    for (int i = 0; i < gv.size(); i++) {
    cout << "gv[ " << gv << "] " <<endl;
    }
    }


    it wont compile and it says:

    vec.cpp:6: error: expected constructor, destructor, or type conversion before '<' token
    vec.cpp:9: error: invalid function declaration

    HELP!
    chardane, Jul 23, 2010
    #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. Sandeep Gupta
    Replies:
    4
    Views:
    14,082
    Sandeep Gupta
    Feb 24, 2004
  2. Michael
    Replies:
    5
    Views:
    18,786
    Maestro
    Sep 17, 2003
  3. Tirenque
    Replies:
    5
    Views:
    9,469
    Charlie Root
    Mar 21, 2006
  4. sjh

    Need Help Initializing Microdrive

    sjh, Dec 7, 2003, in forum: Digital Photography
    Replies:
    2
    Views:
    596
    Roger Halstead
    Dec 9, 2003
  5. dksagra
    Replies:
    0
    Views:
    914
    dksagra
    Jan 14, 2012
Loading...

Share This Page