There is a base class sub, with a member function fnsub(). There are two classes super1 and super2 which are sub classes of the base class sub.if and pointer object is created of the class sub which points to any of the two classes super1 and super2, if fnsub() is called which one will be inoked?



There is a base class sub, with a member function fnsub(). There are two classes super1 and super2 w..

Answer / Shubham Kaushik

"If a pointer to a base class object is pointing to a derived class object, when we call a member function that's present both in the base class and the derived class, the function from the derived class will be called. This is known as polymorphism."n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ Interview Questions

What is an abstract class?

6 Answers   Siemens,


Discuss about iteration statements in C++ .

1 Answers   Agilent,


What Is Polymorphism in C++ ?

3 Answers   IBS, Impetus, ITC Indian Tobacco Company, Motorola,


Identify the errors in the following program. #include <iostream> using namespace std; void main() { int i=5; while(i) { switch(i) { default: case 4: case 5: break; case 1: continue; case 2: case 3: break; } i-; } }

1 Answers  


How many times will this loop execute? Explain your answer.

1 Answers  


What is the difference between malloc, calloc and realloc?

1 Answers   Alter,


It is possible to build a C++ compiler on top of a C compiler. How would you do this?

1 Answers   Amazon,


Identify the error in the following program. include<iostream> using namespace std; void main() { int num[]={1,2,3,4,5,6}; num[1]==[1]num ? cout<<"Success" : cout<<"Error"; }

1 Answers  


What is the difference between virtual functions and pure virtual functions?

2 Answers  


Write a program to read the values a, b and c and display x, where x=a/b–c. Test the program for the following values: (a) a = 250, b = 85, c = 25 (b) a = 300, b = 70, c = 70

1 Answers  


What do you know about Volatile keyword in C++? Explain with an example code.

1 Answers   Adobe,


What is function overloading and operator overloading in C++?

1 Answers   IBS, TCS,


Categories