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?

Answer Posted / qapoo

A function is declared virtual in base class when u are
having same functions in both base and derived classes and
you want to access both the functions with same function
call and its done using base class pointer.
e.g
class base
{
public:
void show(){cout<<"hi"};
};
class derived:pubic base
{
public:
void show(){cout<<"bye";}
};
int main()
{
base *ptr;
base b;
derived d;
ptr=&b;
ptr->show();//base class fn is called
ptr=&d;
ptr->show();//derived class fn is called
return 0;
}

Is This Answer Correct ?    7 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

hi all..i want to know oops concepts clearly can any1 explain??

2141


What is and I oop mean?

1211


class type to basic type conversion

2419


What are the three main types of variables?

1130


Whats oop mean?

1054


What is object in oop?

1121


Is react oop?

1073


What are the 4 main oop principles?

1225


What is destructor example?

1053


Why is static class not inherited?

1108


What are the advantages of polymorphism?

1034


Why do we use polymorphism in oops?

1055


What type of loop is a for loop?

1091


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2465


What is difference between pop and oop?

1170