What is Virtual Keyword?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the different types of qualifier in java?

2005


What do you mean by Encapsulation?

796


Can we define a class within the interface?

776


Why is abstraction used?

821


What is polymorphism in oop example?

715


What is polymorphism and example?

761


What are constructors in oop?

776


What is the real life example of polymorphism?

837


Explain the concepts involved in Object Oriented programming.

853


Can bst contain duplicates?

918


Write a program to compute for numeric grades for a course. The course records are in a file that will serve as the input file. The input file is in exactly the following format: Each line contains a student's first name, then one space, then ten quiz scores all on one line. The quiz scores are in whole number and are separated by one space. Your program will take it input from this file and sends it output to a second file. The data in the output file will be exactly the same as the data in the input file except that there will be one additional number (of type double) at the end of each line. This number will be the average of the student's ten quiz scores. Use at least one function that has file streams as all or some of its arguments.

2793


Why do we use oop?

811


What is the oops and benefits of oops programming?

717


What is the full form of oops?

893


How to call a non virtual function in the derived class by using base class pointer

5871