Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[ 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?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Science For Dummies

Authors: Lillian Pierson ,Jake Porway

2nd Edition

1119327636, 978-1119327639

More Books

Students also viewed these Databases questions