Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
class bowl
4.
{
5.
public:
6.
int apples;
7.
int oranges;
8.
};
9.
int count_fruit(bowl * begin, bowl * end, int bowl :: *fruit)
10.
{
11.
int count = 0;
12.
for (bowl * iterator = begin; iterator != end; ++ iterator)
13.
count += iterator ->* fruit;
14.
return count;
15.
}
16.
int main()
17.
{
18.
bowl bowls[2] = {{ 1, 2 },{ 3, 5 }};
19.
cout
Options:
A .  Executed
B .  Error
C .  Runtime error
D .  None of the mentioned
Answer: Option A

Answer:a
Explanation:
In this program, We are passing the value to the class and adding the values and printing it in the main.
Output:
$ g++ ptm3.cpp
$ a.out
I have 4 apples
I have 7 oranges



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers