good day,
i have base class ,where i have three member functions (actually abstract,no definition)in public access specifier. i derive it in public in my derived classes and each have definition for the base class functions with its private data members . my question is can i use a variable of base class to access the member function of the derived one .if so could you please tell me how.

Hello Vinayak, thank you for the question.

It sounds like you could maybe use a function pointer to accomplish what you want, however, if you have base class methods that you need to access in a derived class, you should strongly consider going ahead and making those methods protected instead of private. A function pointer could be used, but would end up overcomplicating your API, in my opinion.

I hope this information was helpful.

- Eddie


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2017 About.com. All rights reserved.