مرحباً بك،
يمكن تنفيذ المطلوب كالآتي:
#include <iostream>
using namespace std;
class SumProd {
private:
double c;
public:
double a, b;
SumProd(){
a = 0;
b = 0;
c = 0;
cout << "default SumProd constructor called";
}
SumProd(double a_val, double b_val, double c_val) {
a = a_val;
b = b_val;
c = c_val;
}
double sum(){
return a + b + c;
}
double product(){
return a * b * c;
}
void print_c(){
cout << c << endl;
}
};
int main()
{
SumProd obj(2, 4, 6);
obj.print_c();
cout << obj.sum() << endl;
cout << obj.product() << endl;
return 0;
}