G
Guest
Name two cases where you MUST use initialization list as opposed to
assignment in constructors.
assignment in constructors.
?? said:Name two cases where you MUST use initialization list as opposed to
assignment in constructors.
刘昊 said:Name two cases where you MUST use initialization list as opposed to
assignment in constructors.
Gianni said:Only 2 ?
?? said:Name two cases where you MUST use initialization list as opposed to
assignment in constructors.
References and Base Classes are two.
References and Base Classes are two.
Alf said:2. Member variables with user-defined constructors.
Actually, just those missing a default constructor.
Alf said:* Jim Langston:
Language level technical reasons:
1. Base classes.
2. Member variables with user-defined constructors.
3. Member variables with inaccessible or inappropriate assignment operator.
4. "const" member variables.
5. Reference members.
Other technical reasons:
6. When there are dependencies between member variables so that
some must be initialized before one where 1...5 applies.
Non-technical reasons:
7. When the coding guideline or other authority says so.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.