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...

What are Virtual Functions? How to implement virtual
functions in "C" ?

Answer Posted / arati pradhan

A function declared with the keyword virtual, termed as
virtual function.It is used for runtime polymorphism. When
a function is declared as virtual function, the function of
that object is invoked which is refernced by the base
pointer.

Example-
class BASE
{
public:
virtual void show()
{
cout<<"withen base";
}
};
class DERIVED:public BASE
{
public:
void show()
{
cout<<"withen derived";
}
};
void main()
{
BASE *b,b1;
DERIVED d1;
b=&b1;
b->show(); //call the BASE show()
b=&d1;
b->show(); //call the DERIVED show()
getch();
}

Is This Answer Correct ?    9 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a short code using c++ to print out all odd number from 1 to 100 using a for loop

1016


Can turbo c++ run c program?

1092


Is c++ still in demand?

1146


Explain public, protected, private in c++?

1010


Write a recursive program to calculate factorial in c++.

1074


What does the ios::ate argument do?

1185


What is the use of endl?

984


What is c++ programming language?

1096


How do you differentiate between overloading the prefix and postfix increments?

1094


Why do we need function?

1049


Where must the declaration of a friend function appear?

959


I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?

2070


What are the steps in the development cycle?

1097


What is the use of endl in c++?

1015


What is a friend function in c++?

1627