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