Is there a way to call a function in init list with no context of data memeber?
For example this:
class x{
public:
x(char ch): ..., foo() {} // doesn't work
...
void foo(); //foo sets the keys in keys[], different keys for different ch
private:
char keys[10];
}
instead of this:
class x{
public:
x(): ... {foo();}
...
void foo();
private:
char keys[10];
}
Does the init list syntax always have to be {data member name}(value)?
Also, I read that it's preferable to use init list instead of the constructor's function because this way it doesn't make a copy, but in this case does it matter?
Aucun commentaire:
Enregistrer un commentaire