Well... the first bit of code there looks like a function not an object... I will assume that it is your constructor?
In that case:
First I would like to warn you against using arrays of objects -- look into the use of vectors.
Secondly, if you have a default constructor that requires no arguments you will not have a problem creating large numbers of objects
CODE
class foo {
public:
char name[100];
int charAge;
foo(const char *n, const int age)
{
strcpy(name,n);
charAge = age;
}
foo()
{
name[0]=0x00;
charAge = 0;
}
};
int main() {
foo a("Hello", 21);
foo arr[2];
return 0;
}
If you don't have a constructor (and there is no base class, all non-static member are public, and you have no abstract methods) then you can use the struct-array initialization syntax:
CODE
class foo {
public:
char name[100];
int charAge;
};
int main() {
foo arr[2] = {
{"One", 1},
{"Two", 2}
};
return 0;
}
I don't recommend this method as the conditions can be a little hard to keep track of (I had to look them up myself).