1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
AysviL [449]
3 years ago
10

What is printed by the following program provided all necessary standard header files are included? Explain each line of the out

put by stating which member function generates the result and why to justify your answer.#include iostream> using namespace std; class A { public: virtual void f1() cout<<("fl in A/n") voidf2 () { cout << "f2 in A/n";} }class B: public A {public: void f1() cout <<"fl in B/n"; void f2() cout <<"f2 in B/n }void g(A &x){ x.f1(); x.f2(); int main(){A;aB:bg(a);g(b);a.f1();a.f2();b.f1();b.f2();}
Computers and Technology
1 answer:
Ostrovityanka [42]3 years ago
8 0

<u>Output:</u>

f1 in A

f2 in A

f1 in B

f2 in A

f1 in A

f2 in A

f1 in B

f2 in B  

<u>Explanation:</u>

In this snippet, the code makes use of virtual functions. A virtual function is defined as a function that is defined in the base class and redefined in the derived class. If the derived function accesses the virtual function, the program will get executed with the derived class’s version of the function.

In this code, we define the virtual function f1() in class A and also redefine it in class B which is the derived class of A. While executing the program, the function g which takes the object b (class B’s object) as a parameter. It will print class B’s version of f1() rather than class A’s version. This is working off the virtual function.

You might be interested in
If the user inputs “10” for the first expense and “20” for the second expense, what will the interpreter show in the final line
andriy [413]
Yes :) I totally agree with the person above me ^
7 0
3 years ago
Write a function that receives a StaticArray and returns an integer that describes whether the array is sorted. The method must
koban [17]

Answer:

is_sorted(arr: StaticArray) -&gt; int: Write a function that receives a StaticArray and returns an integer that describes whether the array is sorted. The method must return: 1

Explanation:

4 0
2 years ago
Can i have help for a ggogle class room
andrew11 [14]

Answer:

or tell ur teacher to add u in ur class

Explanation:

3 0
3 years ago
Read 2 more answers
Not everything is a success all of the time! So do you know which version of Windows was the least popular?
mario62 [17]

Answer:

windows xp

Explanation:

I think because it is not fast and don't play the games and programs which have higher requirements

7 0
3 years ago
Business application software programs make it possible to
Daniel [21]
Business application software programs make it possible to: increase productivity in the office setting.
Please give me Brainless if this help!!
6 0
3 years ago
Other questions:
  • The reason why a database table is in the first normal form (1NF), but not in the second form (2NF) is because:
    12·1 answer
  • Let L be any r.e. language. We know that there is an unrestricted grammar for L. Show that L can be generated by an unrestricted
    10·1 answer
  • What can be done in order to secure a WLAN/wireless access point?
    12·1 answer
  • Describe what a structure is in a living thing?
    9·1 answer
  • How does the author of let bindi have the limelight persuade readers to consider the importance of wildlife conservation
    9·2 answers
  • Large computer programs, such as operating systems, achieve zero defects prior to release. Group of answer choices True False Pr
    7·1 answer
  • Computer engineering is a career that......
    8·1 answer
  • You can put ______ on your phone.
    10·1 answer
  • You are assigned by your teacher to perform the assembly of all the parts of the computer in preparation for the hands on activi
    7·1 answer
  • You are the IT administrator for a small corporate network. The network uses a DHCP server for IP address configuration for most
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!