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

simple program for virtual function?

Answer Posted / shafi . shaik

//The Concepts of interface classes in Java (Function
Overriding
#include<iostream.h>
#include<conio.h>
class A
{
public:
virtual void cal()
{
}
};
class B:public A
{
public:
void cal()
{
cout<<"Addition"<<10+20;
}
};
class C:public A
{
public:
void cal()
{
cout<<"Multiplication"<<10*20;
}
};
void main()
{
clrscr();
A *p;
B ob;
C ob1;
p=&ob;
p->cal();
p=&ob1;
p->cal();
getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you know the purpose of 'register' keyword?

1064


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

2024


Explain how do you list files in a directory?

1111


How do I use strcmp?

1128


Is c call by value?

1075


How a string is stored in c?

1114


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1131


How can you find out how much memory is available?

1112


What are static variables in c?

1128


Why is c so powerful?

1162


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

1288


How many types of functions are there in c?

1226


Where is volatile variable stored?

1141


What are keywords c?

1089


What functions are used for dynamic memory allocation in c language?

1210