ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C++  >>  OOPS
 
 


 

 
 STL interview questions  STL Interview Questions
 OOPS interview questions  OOPS Interview Questions
 C++ General interview questions  C++ General Interview Questions
Question
what is virtual function?
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what is virtual function?
Answer
# 1
The virtual keyword means that method,property or function 
can be overridden
 
Is This Answer Correct ?    2 Yes 2 No
Jayakrishna Reddy
 
  Re: what is virtual function?
Answer
# 2
virtual function can be used to override the propertis of a 
function.it is normaly used in inheritance. it is part of  
polymerphism.
 
Is This Answer Correct ?    0 Yes 1 No
Kumod
 
 
 
  Re: what is virtual function?
Answer
# 3
virtual function is ended with null 

virtual function=o
 
Is This Answer Correct ?    0 Yes 3 No
Varsha Vilas Kalebag
 
  Re: what is virtual function?
Answer
# 4
It allows one to write generalized code that works with the 
base class pointer which can dynamically point to the 
derieved class objects. Virtual function allows you to 
implement runtime polymorphism. It allows the function call 
to be binded with function definition as late as runtime.

Also read: concept of VPTR and VTABLE from Thinking in C++
 
Is This Answer Correct ?    0 Yes 0 No
Manav Sharma
 
  Re: what is virtual function?
Answer
# 5
When derived class overrides the base class method by 
redefining the same function, then if client wants to 
access redefined the method from derived class through a 
pointer from base class object, then you must define this 
function in base class as virtual function.
 
Is This Answer Correct ?    2 Yes 0 No
Manab
 
  Re: what is virtual function?
Answer
# 6
The objects of the polymorphic class, addressed by 
pointers, change at runtime and respond differently for the 
same message.Such mechanism requres postponment of binding 
of a function call to the member function [ VIRTUAL] untill 
runtime.
 
Is This Answer Correct ?    1 Yes 0 No
Purba Phalguni Mishra, Gandhi
 
  Re: what is virtual function?
Answer
# 7
A virtual function is a function member of a class, 
declared using the "virtual" keyword. A pointer to a 
derived class object may be assigned to a base class 
pointer, and a virtual function called through the pointer. 
If the function is virtual and occurs both in the base 
class and in derived classes, then the right function will 
be picked up based on what the base class pointer "really" 
points at.
 
Is This Answer Correct ?    0 Yes 0 No
Aarti Ashar
 
  Re: what is virtual function?
Answer
# 8
A virtual function is basically a like normal function but 
we can override the function in the derived classes.
Now when we want to access like (fn)

Base * bptr = new Derived();
bptr->fn(); then function of the derived class will be 
called only if the function is marked as virtual in the 
base class.

i.e the virtual keywork tells to use the function of the 
class to which it is pointing to and not to the Base class. 
This is called runtime polymorphism.
 
Is This Answer Correct ?    0 Yes 0 No
Nk
 
  Re: what is virtual function?
Answer
# 9
The virtual function is nothing but the function in the 
base class with the virtual keyword, that allows us to 
derive only once in the class which is going to accsess it 
while it is the child of two different classes which are 
the child of the same base class.This is nothing but the 
dynamic binding.
 
Is This Answer Correct ?    0 Yes 1 No
Gomathisivaram
 
  Re: what is virtual function?
Answer
# 10
A virtual function is a function which is precedded by the 
key word derived is declared in the base class.It is 
normally used to achieve run time polymerphism.That means 
we can override the base class function in the derived 
class.We can invoke the virtual function through the base 
class pointer depending upon the contents to which the base 
class pointer points to.
               Generally the implementation of virtual 
class was found in inheritance where the base class 
function is override in the derived class.
 
Is This Answer Correct ?    0 Yes 1 No
Laxmikant
 
  Re: what is virtual function?
Answer
# 11
virtual function is used to prevent from more times 
calling.That means if a function is declared as virtual 
then its def will be diferent in base class & derived class
 
Is This Answer Correct ?    0 Yes 1 No
Susanta Samal
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
What is the difference between pass by reference and pass by value? TCS6
What is polymorphism? Explain with an example.  7
Why a "operator=(...)" when there is a copy ctor?  2
What is command routing in MFC GE1
Name an advantage of linked list over array? IBM6
what is the difference between class and object?  3
what is virtual function in c++  4
WHY FUCTION OVERLOADING DOSENOT RETURN A RETEN TYPE  1
In the following declaration of main, "int main(int argc, char *argv[])", to what does argv[0] usually correspond? 1) The first argument passed into the program 2) The program name 3) You can't define main like that  4
can you explain how to use JavaBean in Project Infosys1
Why do we use virtual functions?  3
How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization? IntraLogic1
What is the outcome of the line of code "cout<<abs(- 16.5);"? 1) 16 2) 17 3) 16.5 TCS10
Describe the difference between a Thread and a Process?  6
what is the use of mutable key word HCL2
What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?  1
i ahve v low % in 12th n BSC which is aroun 50 coz science was imposed on me......nw m doin MCA n my aggregate in above 74%,what shud i say if asked about low previous percentage??????  3
why c++ is called OOPS? waht is inherutance? what is compiler?  2
What are virtual functions?  2
what is the main difference between c and c++? Microsoft25
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com