Write a C++ class and call it SumProd. The SumProd class should have two public fields
of type double named a and b and one private field of type double named c.
The SumProd class should have default constructor that initializes all its fields to zeros
and prints (default SumProd constructor called) and another constructor that initializes all
its fields to values other than zero.
The SumProd class should also contain a method that returns the sum and of its fields
and another method that returns the product and of its fields.
Create an instance of the SumProd class and initializes its fields to 2, 4 and 6. Then, print
its c field, the sum and product (call the methods you wrote in the class) of its fields.
السؤال
حمامه السلام
Write a C++ class and call it SumProd. The SumProd class should have two public fields
of type double named a and b and one private field of type double named c.
The SumProd class should have default constructor that initializes all its fields to zeros
and prints (default SumProd constructor called) and another constructor that initializes all
its fields to values other than zero.
The SumProd class should also contain a method that returns the sum and of its fields
and another method that returns the product and of its fields.
Create an instance of the SumProd class and initializes its fields to 2, 4 and 6. Then, print
its c field, the sum and product (call the methods you wrote in the class) of its fields.
1 جواب على هذا السؤال
Recommended Posts
انضم إلى النقاش
يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.