Question: [ Prob . 6 . Fundamental of Programming ] ( 1 5 p ) Answer for the following C + + program. #include iostream using

[Prob.6. Fundamental of Programming]
(15p) Answer for the following C++ program.
#include iostream
using namespace std;
class A {
public:
virtual void foo(){ cout "A_foo()" endl; }// same as printf("A_foo()??
; in C
virtual void boo(){ cout "A_boo()" endl; }
};
class B: public A {
public:
virtual void boo(){ cout "B_boo()" endl; }
virtual void zoo(){ cout "B_zoo()" endl; }
};
int main ()
{
B b;
b.foo(); b.zoo();
A**a1=&b;
a1->foo(); a1->boo(); /* HERE */
}
(a) Show the output of the above program (there are four lines).
(b) For the output, which output line(s) correspond to a case where polymorphism,
overriding, and virtual function call occur all together? Explain briefly.
(c) If we add a statement a1->zoo(); at /* HERE */ in the above, can it be compiled
correctly? If so, can it run correctly? If so, what is its output? Explain briefly.
(40p) Answer the following questions in two lines (penalty if more than two lines)
(a) Pointers are tricky to use. Why do we need pointers in programming? That is,
what are pointers mainly used for in CC++ programming?
(b) We can implement a Set using an array or a linked list. What is the advantage
of linked list compared to array? What is the disadvantage?
 [Prob.6. Fundamental of Programming] (15p) Answer for the following C++ program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!