Question: Introduction In this homework, you will do bit operations on various built - in types ( int , char, short, etc. ) using templated classes
Introduction In this homework, you will do bit operations on various builtin types int char, short, etc. using templated classes and iterators. There are two classes: Bitter, which contains the builtin variable and is responsible for gettingsettingmanipulating the bits of the variable content, and BIT erator, which is a friend iterator class for the Bitter class which is used to traverse the bits from left to right from Most Significant Bit MSB to Least Significant Bit LSB Both classes are template classes. Also, you will overload the output stream operator for the Bitter class. In the Bitter class, the bits are counted starting from the right, so the LSB bit is indexed as the one on its left is indexed as etc... Please see the main file which is attached with this homework bundle, and the sample outputs below to understand better what you will implement. Details can be hidden in the main file eg object sharing So please read and analyze the main function and the corresponding outputs very carefully. You will see some int parameters which will be used to represent a bit ie or You are not required to check the validity of these parameters. They will be either or in the tests we will do Do NOT use a library or any other helper class to perform bit operations and implement the functions needed to make the given main function compile, work, and generate the output given in the sample runs below. You are required to use the bitwise operations we saw in the class eg & etc.. The Bitter and BIT erator functions can be seen from the main function file. Note about implementation We are giving the main function in the maincpp file with the homework bundle for you to use. Do not modify the main function. You are asked to use it and implement the other needed classes Bitter and BIT erator within the main.cpp file for the program to work correctly. Please make sure to understand the main function before you start implementing the other needed classes. Sample Runs Some sample runs are given below, but these are not comprehensive; therefore, you have to consider all possible cases to get full marks. Please do not try to understand the requirements by checking out the sample runs details only. They may give you just an idea, but you have to read the requirements from the document to understand fully what to do Below are different values for the variable c in the first two lines of the main function in the main.cpp file, and the expected output. Case : typedef int C; C c ; Expected Output: bitter has value bitter has set bits inside bitter is created from the same object bitter has value flipping the th and rd bits of bitter bitter has value bitter has value bitter has set bits inside setting the st bit of bitter to and rd bit of bitter to bitter has value bitter has value setting the th bit of bitter to set is done successfully bitter has value negating the bits of bitter bitter has value shifting bitter to the left and put for the new bits bitter has value shifting bitter to the right and put for the new bits bitter has value we are using an iterator to obtain the decimal value of bitter value for is value for is Case : typedef char C; C c a; Expected Output: bitter has value bitter has set bits inside bitter is created from the same object bitter has value flipping the th and rd bits of bitter bitter has value bitter has value bitter has set bits inside setting the st bit of bitter to and rd bit of bitter to bitter has value bitter has value setting the th bit of bitter to you are out of index: negating the bits of bitter bitter has value shifting bitter to the left and put for the new bits bitter has value shifting bitter to the right and put for the new bits bitter has value we are using an iterator to obtain the decimal value of bitter value for is value for is Case : typedef short C; C c ; Expected Output: bitter has value bitter has set bits inside bitter is created from the same object bitter has value flipping the th and rd bits of bitter bitter has value bitter has value bitter has set bits inside setting the st bit of bitter to and rd bit of bitter to bitter has value bitter has value
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
