S
Sylvain
Let's say I have the following code where a class 'pipo' has 8 instances
of foo:
class foo
{
foo ( const char * _name):
name = _name
{
}
private:
const char * name;
};
class pipo
{
foo *mf[8];
pipo()
{
for (unsigned int i = 0 ; i < 8; ++i)
{
ostringstream ost;
ost << "MY_FOO_" << i;
string name = ost.str();
mf = new foo (name.c_str());
}
}
};
Is it mandatory to do in such a way: using array of pointers on foo. Or
may I do it by using plain array of instances of foo?
In this case, I have no clue how to process to call the constructor with
the correct C like string as defined in the exemple...
Do you have any ideas how to proceed?
Something like this?
class pipo
{
foo mf[8];
pipo ():
????
{
}
};
Regards
Sylvain
of foo:
class foo
{
foo ( const char * _name):
name = _name
{
}
private:
const char * name;
};
class pipo
{
foo *mf[8];
pipo()
{
for (unsigned int i = 0 ; i < 8; ++i)
{
ostringstream ost;
ost << "MY_FOO_" << i;
string name = ost.str();
mf = new foo (name.c_str());
}
}
};
Is it mandatory to do in such a way: using array of pointers on foo. Or
may I do it by using plain array of instances of foo?
In this case, I have no clue how to process to call the constructor with
the correct C like string as defined in the exemple...
Do you have any ideas how to proceed?
Something like this?
class pipo
{
foo mf[8];
pipo ():
????
{
}
};
Regards
Sylvain