Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In C + + ( make it so that there are two source files: Main.cpp and Byte.cpp , and one header file: Byte.h , and
In Cmake it so that there are two source files: Main.cpp and Byte.cpp and one header file: Byte.h and include all files in the solution please
Modify The Menu
In this assignment you are going to modify the menu you created in Assignment and use the modified version to test your Byte class functionality. In main you should add functionality to the menu that will allow you test the add, sub, mul, div functions in the class. For instance, here is an example of how to test your add functionality:
void byteAdd
int val val;
cout "Enter two whole numbers endl;
Add code to test your add functionality
mwaitKey;
Of course to do this you are also going to need to add this function to your menu:
maddMenu Add Bytes byteAdd;
You are also going to have make a modification to your menu class. Currently it uses an array to hold a fixed amount of menu items. While this may be OK for most applications we want our menu to be as flexible as possible. To make this happen I want you to remove the array of menu items and replace it with a vector.
Modify Byte Class
Replace the int array called bits in the data section of the Byte class with a vector. You should use the vectors constructor to give it a size of At this point it is not going to do much more than the array did but we want to add flexibility for later on
You also must modify your constructors to set the size of the vector. If this is done correctly no other changes need to be made to your code. You should have four constructors, one of them is delegated. This means you need to add code to three of you constructors to resize the vector.
To do this you want to use the two argument resize function that is in vector. The first argument is the size to give the vector. The second argument is the value to fill it with:
vector v; Creates a vector with a size of three each element set to
Overloaded Functions
In the Byte class create the following overloaded functions:
add
sub
mul
div
That take as arguments complex types and return complex types. Reminder that a complex type is a class type.
Example Run
#include
#include
#include "Byte.h
using namespace std;
int main
Byte b;
Byte b;
Byte b baddb;
cout "Int: btoInt endl;
cout "String: btoString endl;
return ;
Int:
String:
Press any key to close this window
Step 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