Monday, 11 September 2017

Important C++ concepts

-static member functions can directly be accessed. No need to create class object for accessing static variables.
-static classes do not exist.

-private constructors:
private  constructors exist, private destructors do not.
private constructors are used to create a singleton class.
http://www.yolinux.com/TUTORIALS/C++Singleton.html

protected constructors also exist. They are created so that only child class can call its constructor.





Virtual Destructors:
virtual destructors exist in C++. If we have a derived class object stored in base class pointer & if we delete that pointer, it will be undefined behaviour. So, we use virtual destructors for this purpose.
http://www.geeksforgeeks.org/virtual-destructor/

virtual constructors do not exist as there will be no point creating an object whose constructor is virtual. Creating an object is a compile time decision.
Except inline no other keyword is allowed with constructors.


Copy Constructor:
http://quiz.geeksforgeeks.org/copy-constructor-in-cpp/
http://www.geeksforgeeks.org/copy-constructor-vs-assignment-operator-in-c/

http://www.geeksforgeeks.org/can-virtual-functions-be-private-in-c/

No comments:

Post a Comment