-
What is the output of this program?
#include <iostream>
using namespace std;
class Car
{
public:
int Lamborghini;
int Audi;
};
int count_CarType(Car * begin, Car * end, int Car :: *CarType)
{
int count = 0;
for (Car * iterator = begin; iterator != end; ++ iterator)
count += iterator ->* CarType;
return count;
}
int main()
{
Car CarArray[5] = {{ 4, 2 },{ 6, 1 }};
cout << "I have " << count_CarType(CarArray, CarArray + 2, & Car :: Lamborghini) << " Lamborghini.\n";
cout << "And I have " << count_CarType(CarArray, CarArray + 2, & Car :: Audi) << " Audi.";
return 0;
}
-
- I have 10 Lamborghini.
- And I have 3 Audi.
- I have 10 Lamborghini.
And I have 3 Audi. - And I have 3 Audi.
I have 10 Lamborghini. - None of these
Correct Option: C
In this program, We are passing the value to the class and adding the values and printing it in the main.