You could down cast the base class pointer to the derived class and call the function.
Base* obj = new Derived;
Derived* d = static_cast<Derived*>( obj );
d->doSomething();
Since doSomething()
is not declared virtual
, you should get the derived implementation.
More Related Contents:
- Why does an overridden function in the derived class hide other overloads of the base class?
- Why doesn’t polymorphism work without pointers/references?
- Overriding a Base’s Overloaded Function in C++ [duplicate]
- C++ inherit from multiple base classes with the same virtual function name
- Size of the classes in case of virtual inheritance
- C++ virtual override functions with same name
- Matrix Printing using Pointers [closed]
- No member named ” in ”. Why did it happen and how do I fix it?
- Accessing class members on a NULL pointer
- Where should I prefer pass-by-reference or pass-by-value?
- Where do “pure virtual function call” crashes come from?
- Top-level const doesn’t influence a function signature
- Is there a way to pass auto as an argument in C++?
- How can I use polymorphic attributes with boost::spirit::qi parsers?
- Using multiple .cpp files in c++ program?
- What are the differences between overriding virtual functions and hiding non-virtual functions?
- Inheritance and method overloading
- Why use a const member function?
- Is there still a use for inline? [duplicate]
- Declare variables at top of function or in separate scopes?
- C++: How to implement polymorphic object creator to populate a table
- Print address of virtual member function
- Pointer to array of unspecified size “(*p)[]” illegal in C++ but legal in C
- About Pointers To Functions in function declarations
- What happens when a function that returns an object ends without a return statement
- Can’t downcast because class is not polymorphic?
- Ad hoc polymorphism and heterogeneous containers with value semantics
- Calling derived class function from base class
- How to properly use system() to execute a command in C++?
- Polymorphism & Pointers to arrays [duplicate]