Q. What is the output of the following C++ code?
Code:#include <iostream>
using namespace std;
class calculate {
int x, y;
public:
void val(int, int);
int sum() {
return (x + y);
}
};
void calculate::val(int a, int b) {
x = a;
y = b;
}
int main() {
calculate calculate;
calculate.val(5, 10);
cout << "The sum = " << calculate.sum();
return 0;
}
β
Correct Answer: (C)
The sum = 15