473,386 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

array too large?

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 ***
--------------------------------------------------
Jul 22 '05 #1
2 4139
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
Jul 22 '05 #2
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
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Yaroslav Bulatov | last post by:
I made an array of 10 million floats timed how long it takes to sum the elements, here's what I got (millis): gcc -O2: 21 Python with numarray: 104 Python with Numeric: 302...
5
by: mark4asp | last post by:
Suppose I wanted to create an array that was associative in 2 dimensions. The rows are associated with numbers. The columns with words. For instance for 3 columns. This array will have 20 rows...
0
by: Marc van Boven | last post by:
I'm stuck with the following problem: My nusoap-client calls a server-function giveCombination(). The function giveCombination should return something like array( => array( 'a_id' => 6,...
12
by: Eigenvector | last post by:
I've been dinking around with this code for a while now and I can't seem to figure out where the problem lies. The original problem was that I for some reason or another couldn't allocate few...
29
by: shmartonak | last post by:
For maximum portability what should the type of an array index be? Can any integer type be used safely? Or should I only use an unsigned type? Or what? If I'm using pointers to access array...
26
by: Brett | last post by:
I have created a structure with five fields. I then create an array of this type of structure and place the structure into an array element. Say index one. I want to assign a value to field3 of...
5
by: apm | last post by:
Any and all: Is there an efficient way to pass a large array from .NET to COM? Can references (or pointer) be passed from COM to NET and NET to COM without the object it refers to being copied?...
7
by: ultr | last post by:
I need a large 3D array of structures: struct s { char a; int b; }; s s_array; s_array is declared as global.
7
by: heddy | last post by:
I have an array of objects. When I use Array.Resize<T>(ref Object,int Newsize); and the newsize is smaller then what the array was previously, are the resources allocated to the objects that are...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.