Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > c++ initializing a vector - please help.

Reply
Thread Tools

c++ initializing a vector - please help.

 
 
chardane chardane is offline
Junior Member
Join Date: Jul 2010
Posts: 1
 
      07-23-2010
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[i] << "] " <<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!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
const vector<A> vs vector<const A> vs const vector<const A> Javier C++ 2 09-04-2007 08:46 PM
Initializing vector<vector<int> > and other vector questions... pmatos C++ 6 04-26-2007 05:39 PM
Initializing a vector of a vector in a constructor fatgirl.brown@gmail.com C++ 4 11-12-2006 09:22 AM
Free memory allocate by a STL vector, vector of vector, map of vector Allerdyce.John@gmail.com C++ 8 02-18-2006 12:48 AM
how the vector is created, how to pass vector to webservices method apachesoap:Vector Rushikesh Joshi Perl Misc 0 07-10-2004 01:04 PM



Advertisments