delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/11/03/09:46:20

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
From: Thomas8675309 AT yahoo DOT com (Tom)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Please help, Problem using vector,
Date: 3 Nov 2003 06:37:41 -0800
Organization: http://groups.google.com
Lines: 44
Message-ID: <7b68d58f.0311030637.7655e157@posting.google.com>
References: <E1AFhRk-0000uP-TR AT t8 DOT cwihosting DOT com>
NNTP-Posting-Host: 63.72.148.162
X-Trace: posting.google.com 1067870262 15609 127.0.0.1 (3 Nov 2003 14:37:42 GMT)
X-Complaints-To: groups-abuse AT google DOT com
NNTP-Posting-Date: Mon, 3 Nov 2003 14:37:42 +0000 (UTC)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"leila" <gcceducate AT tutorialwizard DOT net> wrote:

> Could someone please advise me what I?m doing wrong.  I?m trying to 
> use vector in a simple program.  I'm using this command to compile 
> 
>                      gxx -Wall -o vectorTest.exe vectorTest.cpp
> 
> But I get these errors:
> 
> >>>>>>>>>>>>>>>>>>>>>>>>>>>> error <<<<<<
> vectorTest.cpp: In function `int main()':
> vectorTest.cpp:11: error: `vector' undeclared (first use this function)
> vectorTest.cpp:11: error: (Each undeclared identifier is reported only 
> once for
> each function it appears in.)
> vectorTest.cpp:11: error: parse error before `(' token
> >>>>>>>>>>>>>>>>>>error <<<<<<<<<<<<<<<<<<<<<<<<<
> 
> Here is the relevant part of the code, the error happens on the line I 
> noted with ****
> 
> >>>>> snip <<<<<<<<<<
> #include <iostream>
> #include <vector>
> using namespace std;
> int main()
> {
> 	int val[10] = {1,2,2,2,2,4,7,8,9,6};
> 	int saveVal;
> 	vector v1(val, val+10);    // **** This is where the error starts

std::vector is a template, so you need to specify what type it
contains.  In this case, it's int.  The previous line should therefore
read:

        vector<int>v1(val, val + 10);

As Mr. Broeker suggested, questions like this are probably better
directed to the comp.lang.c++ or comp.lang.c++.moderated newsgroups,
since this type of question isn't djgpp specific.

Best regards,

Tom

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019