www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/07/23:26:28

From: njchack AT my-deja DOT com
Newsgroups: comp.os.msdos.djgpp
Subject: Re: vector of vectors
Date: Fri, 08 Oct 1999 01:22:02 GMT
Organization: Deja.com - Before you buy.
Lines: 43
Message-ID: <7tjgve$ldj$1@nnrp1.deja.com>
References: <37FCEB18 DOT CE7F0A9 AT arcticmail DOT com> <rk6L3.3165$K3 DOT 3734 AT nntp0 DOT detroit DOT mi DOT ameritech DOT net>
NNTP-Posting-Host: 205.200.56.222
X-Article-Creation-Date: Fri Oct 08 01:15:03 1999 GMT
X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 95; DigExt)
X-Http-Proxy: 1.0 x35.deja.com:80 (Squid/1.1.22) for client 205.200.56.222
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

In article "Bradley A. Town" <btown AT nospam DOT com>
wrote:
> Nick,
>     Check out section 16.3.3 in
Stroustrup.  "...operator[]() provides
> unchecked access, whereas at() does a range
check and throw out_of_range if
> an index is out of range."

Yes, but not quite the problem I'm trying to
solve. I understand about checked or unchecked
indexing, but how do I pre-allocate for a
particular size of matrix?

vector<int> a(10); allocates a one-d vector of
ten elements. I want to do something like

vector< vector<int>(10) > a(10); to allocate a
matrix with ten rows and ten columns, instead of
doing

int a[10][10];

I'm not sure this is possible with the STL.
Perhaps I need to write a two-d matrix class?

Nick.



>
> ---
> Bradley A. Town
> Lead Software Engineer
> Test Products, Inc.
> E-mail:  btown at testprod.com
>
>



Sent via Deja.com http://www.deja.com/
Before you buy.

- Raw text -


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