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 is Virtual Keyword?

Answers were Sorted based on User's Feedback



What is Virtual Keyword?..

Answer / anamika

with help of virtual keyword we can call all the funtion of
same name used in different class by creating pointer of
the base class

Is This Answer Correct ?    18 Yes 1 No

What is Virtual Keyword?..

Answer / srinivas amdduri

Using Virtual keyword we can override method.otherwise u
can go with sealed class.

Is This Answer Correct ?    13 Yes 3 No

What is Virtual Keyword?..

Answer / jyoti bajaj

virtual keyword can be used with base classes as well as
with functions.Here we are talking about virtual base
classes.
class A
{
public:
A(){cout<<"it is class A"<<endl;}
};
class B:public A
{
public:
B(){cout<<"it is class B"<<endl;}
};
class C:public A
{
public:
C(){cout<<"it is class C"<<endl;}
};
class D:public B,public C
{
public:
D(){}
};
void main()
{
D obj;
}
output:
it is class A
it is class B
it is class A
it is class C

since class A is constructed twice.but if we want that only
one copy of class A should be shared by both classes A &
B.so we inherit the base class by using virtual keyword.

class A
{
public:
A(){cout<<"it is class A"<<endl;}
};
class B:virtual public A
{
public:
B(){cout<<"it is class B"<<endl;}
};
class C:virtual public A
{
public:
C(){cout<<"it is class C"<<endl;}
};
class D:public B,public C
{
public:
D(){}
};
void main()
{
D obj;
}
output:
it is class A
it is class B
it is class C

Is This Answer Correct ?    5 Yes 0 No

What is Virtual Keyword?..

Answer / tamil venthan

using virtual we can override the same function for
different sub classes ,By creating the pointer to the base
class we can allocate the separate memory for every
class(memory consumption)not for all classes

Is This Answer Correct ?    5 Yes 1 No

What is Virtual Keyword?..

Answer / danish afzal

Virtual is important part of polymorphism,and if a function of a base class is virtual we can use or override it in drived classes.

class base
{
virtual void foo() const
{
cout << "danish B";
}
};
class derived1 :public base
{
void foo() const
{
cout << "danish D1";
}

};
class derived2 :public base
{
void foo() const
{
cout << "danish D2";
}

};

Is This Answer Correct ?    4 Yes 1 No

What is Virtual Keyword?..

Answer / giri

Virtual keywork is important functionality in C++. We used
virtual class/ function to access function run time.
Virtual function is override the same function in derived
classs and can access through run time using Upcasting.

Is This Answer Correct ?    0 Yes 0 No

What is Virtual Keyword?..

Answer / devi

The Keyword virtual provides a mechanism for defining the
virtual functions.When declaring the base class member
function,the keyword virtual is used with those
functions,which are to be bound dynamically.

Is This Answer Correct ?    0 Yes 1 No

What is Virtual Keyword?..

Answer / p.madhupriya

virtual keyword we can call all the funtion of
same name used in different class by creating pointer of
the base class

Is This Answer Correct ?    0 Yes 1 No

What is Virtual Keyword?..

Answer / deepak kumar

using virtual keyword we can change the defination of base
class method via overriding them in derived class.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More OOPS Interview Questions

Get me an image implementation program.

0 Answers  


When will a constructor executed?

5 Answers   TCS,


Why do we use polymorphism?

0 Answers  


Which type does string inherit from?

0 Answers  


What is an example of genetic polymorphism?

0 Answers  


what is the use of template classes in c++

1 Answers  


What is oops concept with example?

0 Answers  


what is the basic concept of inheritance?

9 Answers  


Which keyword is written to use a variable declared in one class in the other class?

5 Answers   TCS,


How to reverse a sentence in c program ex: ram is a good boy answer: boy good a is ram

0 Answers   IBM,


some one give d clear explanation for polymorphism

3 Answers  


Define a class to represent a bank account. Include the following members: Data Members: Name of the Depositor Account Number Type of Account Balance amount in the account Member Functions: To assign the initial values. To deposit an account. To withdraw an amount after checking the balance. Write a C++ main program to display account number, name and balance.

6 Answers  


Categories