I have a member variable that is a class that prohibits copying (copy assignment operator is deleted). I want to make some checks to determine what to initiate the member to, thus I need to do this inside the constructor and not in and initializer list. It seem the member variable m is already initialed with the default constructor before entering the constructor of MyClass, then what is the point of the constructor... sorry for c++ rant.
Simple example:
class MyClass { NonCopy m; MyClass() { // Complex checks if(success) { m("success"); else { m("failure"); } } The options I see is:
- Reside to dynamic allocation of m
- Relax copy prohibit requirement of m