If an class is allowed to copy and assign (e.g. a proto class), it's better to just assign an instance to the class. For example, the configuration proto. If the class is not allowed to copy and assign, allocate the memory on heap and let some class to take the ownership.
NEVER use a class pointer member to point to some class's member on the stack. It can cause very weird segment fault crash and it's very hard to debug.
No comments:
Post a Comment