Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > array too large?

Reply
Thread Tools

array too large?

 
 
Developwebsites
Guest
Posts: n/a
 
      12-18-2003
const int MAX=999;

class person {
protected:
char firstname[MAX][MAX],
lastname[MAX][MAX];
int ID[MAX];

public:
person();
};

I get an array size too large error.
Is 999x999 array too large or is a single 999 array too large?

--------------------------------------------------
*** E-mail is shut off ***
--------------------------------------------------
 
Reply With Quote
 
 
 
 
Christoph Rabel
Guest
Posts: n/a
 
      12-18-2003
Hi!

Developwebsites wrote:
> const int MAX=999;
>
> class person {
> protected:
> char firstname[MAX][MAX],
> lastname[MAX][MAX];


Why do you need such a big 2 dimensional array for
firstname? Looks weird to me.

> int ID[MAX];
>
> public:
> person();
> };
>
> I get an array size too large error.
> Is 999x999 array too large or is a single 999 array too large?


Most Compilers set a limit to the size of arrays on the
stack. About 1 Million byte is probably too much...

Your class design looks very weird to me. I think you are
wasting a lot of memory.

So: Dont use a buildin array, use std::vector!

class person {
protected:
vector<string> firstname;
vector<string> lastname;
vector <int> ID;

public:
person();
};

Im not quite sure why a person should have more then one
lastname, but maybe I misunderstand your intention.

Or maybe you want to create an array of several persons.
In this case I would do it about this way:

class Person {
std::string firstname;
std::string firstname;
int id;
public:
// Some methods here

};

class Persons {
vector<Person> persons;
// Some methods here
};

hth,

Christoph
 
Reply With Quote
 
 
 
 
Hendrik Belitz
Guest
Posts: n/a
 
      12-19-2003
Developwebsites wrote:

> const int MAX=999;
>
> class person {
> protected:
> char firstname[MAX][MAX],
> lastname[MAX][MAX];
> int ID[MAX];
>
> public:
> person();
> };
>
> I get an array size too large error.
> Is 999x999 array too large or is a single 999 array too large?


Maybe you could tell me which OS and Compiler you are using? I'm working on
arrays that are much larger and got no "array too large" error so far.

--
Dipl.-Inform. Hendrik Belitz
Central Laboratory of Electronics
Research Center Juelich
 
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
Smart Client Assembly.. what is too big or too small ??? Martin ASP .Net 0 08-04-2004 08:47 AM
Are these pictures too dark or/and too large? Luigi Donatello Asero HTML 13 05-21-2004 04:54 AM
Problems with imaging (too slow or too much RAM) SB Java 0 08-05-2003 11:06 AM
Re: Is this just too hard for folks here? Or too stupid? Mark Parnell HTML 0 06-23-2003 11:02 PM
Re: Is this just too hard for folks here? Or too stupid? Mike Foster HTML 0 06-23-2003 07:14 PM



Advertisments