vendredi 11 décembre 2020

how to print out the operation that I have used

I have made a class

class CompositeNumber : public Number

And I have included the information that needs to be stored which are

Number* first;
Number* second;

Now I have been told "mainly the other numbers from which it was composed (so it can be split again), the operation that was used (+, -, *, /) for printing, and possibly its value (for convenience, so you don't have to re-compute it all the time)" but I have no clue how to do that at all.

Here is the whole code that I have done so far for the CompositeNumber class

class CompositeNumber : public Number {
Number* first;
Number* second;

int getValue;


bool isSpittable() {
    return true;
}

public: void printMe() {

/*cout << "1 . Add = +" << endl;
cout << "2 . Subtract = -" << endl;
cout << "3 . Multiply = *" << endl;
cout << "4 . Divide = /" << endl;
*/

cout << getValue;
}
};

Aucun commentaire:

Enregistrer un commentaire