What is theoutput produced when the following code iscompiled andexecuted? #incl
ID: 3613283 • Letter: W
Question
What is theoutput produced when the following code iscompiled
andexecuted?
#include<iostream>
usingnamespace std; //introduces namespacestd
classB
{
public:
void f(intx);
virtual voidg(int x);
};
class D :public B
{
public:
void f(intx);
void g(intx);
};
void B::f(intx)
{cout<< "BF ";}
void B::g(intx)
{cout<< "BG ";}
void D::f(intx)
{cout<< "DF ";}
void D::g(intx)
{cout<< "DG ";}
CMPE101Example Exam Questions and Possible Answers. TheCorrect
answer is notprovided. June 5, 2005
5
intmain()
{
Dd;
B *bp =&d;
D *dp =&d;
bp ->f(3);
dp ->f(4);
bp ->g(5);
dp ->g(6);
return0;
}
a)DF
BF
DG
DG
b)BF
DF
DG
DG
c)BF
DF
DG
DF
d) No outputwill be generated because the code will notcompile
e) No outputwill be generated because executing the codewill
cause the program to endabnormally.
Explanation / Answer
Dear... The output of the given code is BFDF
DG
DG Hope this willlhelp you...
Hope this willlhelp you...
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.