delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/08/20/14:31:39

From: "jansb000" <jansb000 AT wxs DOT nl>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Q: 2 dimensional array with STL is possible?
Date: Mon, 20 Aug 2001 20:26:49 +0200
Organization: Planet Internet
Lines: 28
Message-ID: <9lrk0v$3680a$1@reader01.wxs.nl>
References: <9lor3c$37cki$1 AT reader02 DOT wxs DOT nl> <837kvzg30b DOT fsf AT mercury DOT bitbucket>
NNTP-Posting-Host: ipc3797b20.dial.wxs.nl
X-Trace: reader01.wxs.nl 998331231 3350538 195.121.123.32 (20 Aug 2001 18:13:51 GMT)
X-Complaints-To: abuse AT wxs DOT nl
NNTP-Posting-Date: 20 Aug 2001 18:13:51 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Nate Eldredge" <neldredge AT hmc DOT edu> wrote

> That seems like it would work, although I don't know for sure.  Why
> not try it?

I did, the compiler seems to accept it, but I got stuck in really using the
2D array.

For example (1):

vector< vector<int> > arint;
arint.resize(20); // gives a list of 20 times vector<int>.
for (int i = 0; i < arint.size(); i++) arint[i].resize(20); // Compiler
complains...

For example (2):

vector<int> row;
row.resize(20);
vector< vector<int> > arint;
for (int i = 0; i < 20; i++) arint.push_back(row); // Compiler accepts...
arint[5][4] = 12; // Compiler complains...

I forgot the exact messages from the compiler. At this point I decided to
first consult the newsgroup before going any further.



- Raw text -


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