The constructors can't declared as virtual but the destructors can be declared as virtual.why?
solution:
The virtual keyword is used in C++ when we need dynamic behavior. It will work only when objects exists where constructors are used to create objects. Constructors will be call at the time of object creation.So if we define the constructor as virtual,it should have existing object to use. But the object is created at the time of constructor call. Thus this is contradictory.
Again we can't override the constructor,when any method is declared as virtual,it should be overridden in its derived class. Since constructor is used for initializing variables of a class and it can be defined only within the class ,it can't be overridden. Thus the constructor can't be declared as virtual. We can use virtual destructor because, at the time of calling destructor,we have the objects .So we can use virtual keyword for the destructors.