Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to call a non virtual function in the derived class by
using base class pointer

Answer Posted / ak

It's simple.
Since in question it is asked how to call "non virtual
function in derived class" which means in derived class we
need to access non-virtual function using Base Class's pointer.

Note:
In question its no where mentioned that we cannot use
virtual function in Base class.


So in Base class same function can be made virtual and we
can use it through Base's pointer.



See eg. below:


class Base
{
public:
virtual void fun()
{
cout<<"Inside Base's fun";
}

};


class Derived : public Base
{
public:
void fun()
{
cout<<"Inside Derived's fun";
}


};



int main()
{

Base *bp = new Derived;
bp->fun();



getch();
}

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the benefits of interface?

1001


Explain the advantages of inheritance.

1090


write a program to enter a string like"sunil is a good boy and seeking for a job" not more than 10 characters including space in one line,rest characters should b in other line.if the next line starts from in between the previous word,then print whole word to next line.

2196


What makes a language oop?

1011


What polymorphism means?

1007


What is polymorphism explain its types?

1105


What are the benefits of oop?

1179


What is difference between multiple inheritance and multilevel inheritance?

1112


any one please tell me the purpose of operator overloading

2344


INSTANCE FIELDS DECLARED private ARE ACCESSIBLE BY THE METHODS ONLY.CAN WE CHANGE THE private FIELD OF AN OBJECT IN A METHOD OF SOME OTHER OBJECT OF THE SAME CLASS?

2155


How to hide the base class functionality in Inheritance?

1101


Why do pointers exist?

1050


What is object and class in oops?

1009


They started with the brief introduction followed by few basic C++ questions on polumorphism, inheritance and then virtual functions. What is polymorphims? How you will access polymorphic functions in C? How virtual function mechanism works?

1879


What is the purpose of polymorphism?

1093