Question: c++ code Let's make a wrapper class (i.e., a class that adds additional functionality to a given type) for an int. Specifically, make a class

 c++ code Let's make a wrapper class (i.e., a class that

c++ code

Let's make a wrapper class (i.e., a class that adds "additional functionality" to a given type) for an int. Specifically, make a class called Int (note the capital I), which has the following data and attributes val - internal int data. This is not how encryption works in the real world. A constructor that takes one parameter and initializes val accordingly. numSetBits) - returns the number of bits that are set to 1 in val, as an int. longestGap) if val contains the sequence of bits 1001, where the ..- does not contain any 1s, then we say that this is a gap. This function will return the length of the longest gap in val (if there is not such a gap, return 0). For instance, if the longest gap happens to be 10001, then you will return 3. All gaps must start and end with a 1. setBit(int) w take an integer index as input, say it is i, and will set the ith bit in val If i is strictly less than 0 or larger than 32, then don't modify val. If it is between 0 and 32, then set the bit to 1 if it is not already. This function does not return anything. . flipBit (int)-same as setBit but will flip the bit's value (i.e., if it is 1, change it to 0, and vice versa invert will flip all of the bits within val, and does not return anything. A getter for val (no setter for this class) Save the class in a header file called Int.h, and the implementation of all the functions must be in the corresponding implementation file Int.cpp. Nothing should be printed to the user in this class, only returning the values as appropriate

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!