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

What is the use of c++ programming language in real life?

1095


program explaining feautures of c++

2492


What is near, far and huge pointers? How many bytes are occupied by them?

1159


Explain about templates of C++.

1199


Explain the difference between class and struct in c++?

1106


What is the syntax for a for loop?

1200


Is it possible to have a recursive inline function in c++?

1073


What is the header file for setw?

1192


Why was c++ made?

1146


Explain rethrowing exceptions with an example?

1075


What is token c++?

1089


What is an undefined behavior and sequence points

1055


What is the best it certification?

1161


Is the declaration of a class its interface or its implementation?

1226


What is the equivalent of Pascal's Real a) unsigned int b) float c) char

1060