C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 38)
38.
What happens if the base and derived class contains definition of a function with same prototype?
Discussion:
22 comments Page 2 of 3.
Pallavi said:
1 decade ago
We can declare both base & derived class objects and as per that we can directly call the functions of that class.
Pooja said:
1 decade ago
It will raised an ambiguity error cause compiler will confused when we create the object of derived class.
Swapnil said:
8 years ago
If virtual not used so only baser class function is called. If virtual keyword used so both can be called.
Yogita said:
1 decade ago
I also agree with option B because both class contain same prototype. Prefrence gives to base class.
Dhanesh ful said:
1 decade ago
This example of method overrding only the the method of derived class is call istead of base class.
Ramanagarjuna R K said:
9 years ago
Yes, only base class function will be invoked irrespective of an object.
So, the answer is B.
So, the answer is B.
Vishal Tavande said:
1 decade ago
Only base class function will get called irrespective of object. As I tried this at my desk.
Sona said:
1 decade ago
The answer given is right as it totally depends on calling class object.
Mangesh said:
9 years ago
D option is correct without doubt. I agree with the given answer.
Anisha said:
9 years ago
Yes, it's B. Agree with the above explanation.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers