بصراحه انا فاهم الدرس بس مافهمت هالسؤالين ممكن احد فاهمهم يوضح لي المطلوب عشان احله
Create a Class called Rational for performing arithmetic with functions. Write a program to test your class.
· The class contain two data members The numerator and the denominator (all of them of type int).
· Provide a constructor that enables an object of this class to be initialized when it's declared (Parameterized constructor). The constructor should contain default values in case no initializes are provided for the two data members.
· You know the fraction should be stored in reduced form. For example, the fraction would be stored in the object as 1 in the numerator and 2 in the denominator.
· Provide public member functions that perform each of the following tasks:
A) Adding two Rational(Fractional) numbers. The result should be stored in reduced form.
B) Subtracting two rational numbers (Fractional) . The result should be stored in reduced form.
C)Multiplying two rational numbers (Fractional). The result should be stored in reduced form.
d) Dividing two rational numbers (Fractional). The result should be stored in reduced form.
E)Printing rational numbers (Fractional) in the form a/b, where a is the numerator and b is the denominator.
f) Printing rational numbers (Fractional) in floating point format.
· Write a test program that demonstrates class Rational’s capabilities. In this class provide a destructor that prints a message "Destructor called". In the main create two objects and test all functions for each object.
Hint: Split the class from the implementation (Retional.h, Retional.cpp, Main.cpp)
Create a class called Trace that trace the code by printing a messages,
· The Class includes a data member : ObjName.
· The Class includes a member function that set and return a data memer.
· Your class should have constructor that initializes the data members and prints "Default constructor is called for…" and the ObjName.
· Define a constructor that gets one arguments and assigns them to ObjName and prints "Parameterized constructor is called for…" and the ObjName.
· Define a destructor which prints “Destructor is called for…” and print the ObjName.
· Create three types of objects : Local and Static local (inside the main ), Global.
Hint: 1- local object has no initial value allow user to enter object name, static object has initial name "static", global object also has initial name "global".
2-Split the class from the implementation (Trace.h, Trace.cpp, Main.cpp)