It is often recommended that class objects be initialized using direct constructors rather than assignment. \ [[Meyers 01|AA. Bibliography#Meyers 01] \] Direct constructors avoids construction, copying, and destruction of a temporary copy of the object. To wit, object should be constructed this way: Wiki Markup
Code Block | ||||
---|---|---|---|---|
| ||||
Widget w( /* constructor arguments */); |
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
OOP31-CPP | low | likely | low | P9 | L2 |
Bibliography
...
...
OOP30-CPP. Do not invoke virtual functions from constructors or destructors 13. Object Oriented Programming (OOP) OOP33-CPP. Do not slice polymorphic objects