C++ - when should I use a pointer member in a class -
C ++ (and Direct 3D, but sometime ago) I have been confused with learning when you In the class, an indicator member should be used. For example, I can use a non-pointer declaration:
Private: SomeClass instance_;
Or can I use an indicator declaration
private: someclass * instance_
and then the new one Use () on it in the manufacturer
I understand that if some class can be obtained from another class, a COM object or ABC, then it should be an indicator whether there are any other guidelines Should i be aware about
The following advantages of an indicator are:
a) You make a lazy start It means that to minimize the object / object before the first actual use.
B: Design: If you use pointers for outsiders class types, you can make a further announcement over your class and thus include headings of that type in your header No need - instead of your own. CPP can include third party headers - it's time to minimize the advantage, compile time and inhibit side effects by including several other headers.
class ExtCamera; // "Extcamera H" class in MicraMma {public: MacMera (): M_Picamera (0) {} Further announcement for external class type in Zero Init (Const ExtCamera and Camera); Private: ExtCamera * m_pCamera; // Do not use it in inline code inside the header! };
c) An indicator can be removed at any time - so you can have more control about livtime and create an object again - for example the case of failure In.
Comments
Post a Comment