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 is the difference between a mixin and inheritance?

992


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

2158


Why is object oriented programming so hard?

1089


Plese get me a perfect C++ program for railway/airway reservation with all details.

3909


What is the point of oop?

1192


Is react oop?

1073


What are the components of marker interface?

1062


What is abstraction and encapsulation?

1022


What is object in oop?

1121


What are classes oop?

1035


Why polymorphism is used in oops?

1053


There are two base class B1,B2 and there is one class D which is derived from both classes, Explain the flow of calling constructors and destructors when an object of derived class is instantiated.

2000


What is overloading in oop?

1012


What is the real time example of encapsulation?

1070


Where You Can Use Interface in your Project

1893