Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(a) Draw a class diagram representing the classes declared below. (b) Declare these classes in a file entitled BinaryOperators.h, inserting appropriate pre-compilation directives. Define
(a) Draw a class diagram representing the classes declared below. (b) Declare these classes in a file entitled "BinaryOperators.h", inserting appropriate pre-compilation directives. Define all the non-abstract methods in a source file entitled "BinaryOperators.cpp". Include also the definition of the function Test(). In this function use polymorphism to compute the following: 8+9, 8-9, 8*9, 8/9, 8/0. (c) Define main) in a source file entitled "main.cpp". Call Test) in main(). (d) Run you program and turn in the header files, source files, and the output of your program. class Binaryoperator ( public: Binaryoperator ( double opl, double op2 ) : f0pl ( opl ), fop2 ( op2 ) {} virtual double DoOp () const = 0; protected: const double fopl; const double fop2; }; // class Binaryoperator class Adder : public Binaryoperator { public: Adder ( double opl, double op2 ) : Binaryoperator ( opl, op2 ) {} virtual double DoOp () const; }; // class Adder class Subtractor : public Binaryoperator { public: Subtractor ( double opl, double op2) : Binaryoperator ( opl, op2 ) {} virtual double DoOp () const; }; // class Subtractor class Multiplier : public BinaryOperator { public: Multiplier ( double opl, double op2 ) : BinaryOperator ( opl, op2 ) {} virtual double DoOp () const; }; // class Multiplier class Divider : public Binaryoperator { public: Divider ( double opl, double op2 ) : BinaryOperator ( opl, op2 ) (0 virtual double DoOp () const; }; // class v void Test () ;
Step by Step Solution
★★★★★
3.31 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
Solution output Adder o...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started