what is virtual function in c++

Answer Posted / b.balaganesan

Virtual, as the name implies, is something that exists in
effect but not in reality. The concept of virtual function
is the same as a function, but it does not really exist
although it appears in needed places in a program. The
object-oriented programming language C++ implements the
concept of virtual function as a simple member function,
like all member functions of the class.

Need for Virtual Function:

The vital reason for having a virtual function is to
implement a different functionality in the derived class.

For example: a Make function in a class Vehicle may have to
make a Vehicle with red color. A class called FourWheeler,
derived or inherited from Vehicle, may have to use a blue
background and 4 tires as wheels. For this scenario, the
Make function for FourWheeler should now have a different
functionality from the one at the class called Vehicle.
This concept is called Virtual Function.

Is This Answer Correct ?    10 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between abstraction and polymorphism?

619


Can abstract class have normal methods?

616


Is enum a class?

607


Why is polymorphism important in oop?

637


given a set based questions and 5 questions based on it next data sufficiciency questions 2 and 2/3 english sentence completion with options very easy and 2 synononmys paragraph with 10 questions 10 minutes replace =,-,*,% with -,%,+,* type questions 5 3 questions lik following itssickhere itssickthere itssickhere istsickhere which is nt alike the others very easy

2150






What is static in oop?

591


any one please tell me the purpose of operator overloading

1967


What is the oops and benefits of oops programming?

556


Why is oop better than procedural?

606


Whats is abstraction in oops?

593


what is graphics

2013


What is the problem with multiple inheritance?

587


Can a varargs method be overloaded?

618


What are the important components of cohesion?

557


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

700