delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/01/17:19:12

From: karpfenteich AT gmx DOT de (Peter Karp)
Newsgroups: comp.os.msdos.djgpp
Subject: vector (STL) at() doesn't work in DJGPP?
Date: Tue, 01 Feb 2000 16:34:59 GMT
Organization: 1&1 Telekommunikation GmbH
Lines: 36
Message-ID: <38970956.7167311@news.online.de>
NNTP-Posting-Host: p3e9be96b.dip0.t-ipconnect.de
X-Trace: news.online.de 949422692 11617 62.155.233.107 (1 Feb 2000 16:31:32 GMT)
X-Complaints-To: abuse AT online DOT de
NNTP-Posting-Date: 1 Feb 2000 16:31:32 GMT
X-Newsreader: Forte Free Agent 1.11/32.235
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hi,

I'm still learning to use the containers and have some beginner's
questions regarding the <vector> of the STL.

Compiling...

int main()
{
vector<double> v;
cout << "Type in the first element of the vector: " << endl;
double x;
cin >> x;
v.push_back(x);
cout << " First element (index zero): " << v.at(0);
return 0;
}


...gives the following error message:

E:\aa\cpp>gxx kurz.cpp
kurz.cpp: In function `int main()':
kurz.cpp:30: no matching function for call to
`vector<double,allocator<double> >
::at (int)'

while the same program compiles (and runs) without a problem with
VC++6.

When I change v.at(0) to v[0] DJGPP doesn't have any problems either.
But I'd like to know why at() doesn't works (which would be better to
use sometimes as it checks if the range is valid) here.

Greetings from Cologne
Peter

- Raw text -


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