Calling constructor
From: Sylvain (sylvain.boucher_at_aitb.org)
Date: 02/12/04
- Next message: Jerry Coffin: "Re: strftime not working as expected"
- Previous message: Mike Wahler: "Re: file stream open failure reason"
- Next in thread: Victor Bazarov: "Re: Calling constructor"
- Reply: Victor Bazarov: "Re: Calling constructor"
- Reply: Ron Natalie: "Re: Calling constructor"
- Reply: Cy Edmunds: "Re: Calling constructor"
- Reply: Alf P. Steinbach: "Re: Calling constructor"
- Reply: John Carson: "Re: Calling constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 12 Feb 2004 20:00:24 +0100
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[i] = 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
- Next message: Jerry Coffin: "Re: strftime not working as expected"
- Previous message: Mike Wahler: "Re: file stream open failure reason"
- Next in thread: Victor Bazarov: "Re: Calling constructor"
- Reply: Victor Bazarov: "Re: Calling constructor"
- Reply: Ron Natalie: "Re: Calling constructor"
- Reply: Cy Edmunds: "Re: Calling constructor"
- Reply: Alf P. Steinbach: "Re: Calling constructor"
- Reply: John Carson: "Re: Calling constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|