Question
C++ please I need the coressponding .cpp file created for the given .h file. I have yet to write the main function for this class
C++ please
I need the coressponding .cpp file created for the given .h file.
I have yet to write the main function for this class
Nothing given can be changed
GENERAL RESTRICTIONS
No global variables
No labels or go-to statements
No infinite loops, examples include:
for(;;)
while(1)
while(true)
do{//code}while(1);
No break statements to exit loops
#ifndef Subtraction_h
#define Subtraction_h
#include
#include
using namespace std;
class Subtraction
{
//Overload the stream insertion and extraction operators
friend ostream& operator
public:
Subtraction();
//default constructor
//Postcondition: theAnswer=0; userResponse=0;
//invokes randomize();
void randomize();
//Function to generate two random numbers between 1 and 10.
//Postcondition: num1 and num2 are equal to between 1 and 10;
//and theAnswer = num1 - num2;
bool checkAnswer();
//Function to check userAnswer with problem answer (theAnswer)
//Postcondition: if theAnswer==userResponse appropriate feedback is displayed
// returns true if user answer is correct or returns false if user answer is incorrect;
void validate(string str1);
//Function to validate user response
//Postcondition: function accepts a string, validates it to be an int;
private:
int num1;//variable to store one of the operands
int num2;//variable to store one of the operands
int theAnswer;//variable to store the answer to the problem
int userResponse;//variable to store the user response to the problem in int format
};
#endif
1 #ifndef Subtractionh - #define Subtractionh - 4 #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
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