Computer scienceProgramming languagesC++Basics of object-oriented programming

Constructors and destructors

Theory

Errors

Report a typo

Our programmer forgot to implement something. Correct this mistake for him.

Sample Input 1:

1 1

Sample Output 1:

2
1
1
0
Write a program in C++
class Calc {
private:
double a;
double b;
public:

double addition() {
return a + b;
}

double multiplication() {
return a * b;
}

double division() {
if (b != 0)
return a / b;
else
std::cout << "Division by zero is not allowed." << std::endl;
}

double subtraction() {
return a - b;
}
};

Create a free account to access the full topic