A
Anthony
Hello All,
Say I have a class foo, how can I instantiate say 5 of them and store
information about each in an array?
I am open to any other approach that may be useful. Thanks, help is
appreciated.
-Anthony
class foo
{
public:
int num;
foo(int val) : num(val) { }
}
int main (int argc, char ** argv)
{
int rval = 0;
foo f[5] = {1, 2, 3, 4 , 5};
for (int i = 0; i < sizeof(f) / sizeof(*f); i++)
cout << f.num << endl;
return rval;
}
Say I have a class foo, how can I instantiate say 5 of them and store
information about each in an array?
I am open to any other approach that may be useful. Thanks, help is
appreciated.
-Anthony
class foo
{
public:
int num;
foo(int val) : num(val) { }
}
int main (int argc, char ** argv)
{
int rval = 0;
foo f[5] = {1, 2, 3, 4 , 5};
for (int i = 0; i < sizeof(f) / sizeof(*f); i++)
cout << f.num << endl;
return rval;
}