Question: Consider the following code fragment. What do we need to enforce on function myFun() so that classes BBB and CCC can be used polymorphically?

Consider the following code fragment. What do we need to enforce on function myFun() so that classes BBB and 

Consider the following code fragment. What do we need to enforce on function myFun() so that classes BBB and CCC can be used polymorphically? class AAA {my Fun() {}; }; class BBB: public AAA {...}; class CCC: public AAA {...}; void main() { AAA* aaaPtr aaaPtr = new CCC (); aaaPtr any Function () %; aaaPtr = new BBB (); aaaPtr any Function () %; }

Step by Step Solution

3.54 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The code snippet you provided defines three classes AAA BBB and CCC Class BBB and CCC inherit from class AAA The myFun function is likely intended to be polymorphic meaning it should be able to handle ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!