Dear all,

I have some questions in C++ which I could not get clear answers through internet. It would be very helpful if you could help with it.

1. How to instantiate a non-pure abstract class ( only one of the data members is made pure virtual) in the main(). In internet it is mentioned that, it is possible to create my own constructor to initialize the property members and to use the non-virtual methods. is it possible?. or should the non-pure virtual members can be made static?

2. Some say, that it is even possible to create a non-pure abstract class just my making the destructor as pure virtual, it is possible?

3. What is the actual useof pure virtual destructor in the program actually?

4. Is it possible to use the auto type as return value in case of abstract function? Is it possible to know the type of data carried by auto variable?

5. why sometimes the constructor is made protected, is it liberately done to prevent direct instantiation? what are all the use cases of such practice?

6.If I call a virtual function in the derived class, it takes the default value of that function from base class always, how to override it? why it happens?

7. In multiple inheritance, why I make a class virtual to avoid multiple copies of a same base class, it does not work?

8. Interestingly, if I call the grandchildren class (in multiple inheritance)

class A(contains virtual members) : class B ( non virtual members)

class B : class C ( non virtual members)

class C: class D ( non virtual members)

9. If there is a non-pure abstract class( only one of the members is pure virutal), can I again define it as pure virtual if there is no body/definition literally available in one of the derived class, instead of defining it just for the sake of abstract class instantiation?

if I access the class D object, using the class B/C type pointer, provided that the base class A member function made virtual, the members of the class D is accessed instead of class B. Can I understand that any base class member irrespective of what you use becomes virtual even if one of the base class instance of that member is made virtual?

Hope my questions were clear. Would be glad to provide an example code if required.

Thank you and I look forward to hearing from you.

More Raam Kasinathan's questions See All
Similar questions and discussions