subject

Define a class named Bits that holds a single integer variable. You will use this integer simply as a container of bits. The number of bits you can support depends on the type of integer you use. We will use an unsigned long long, which on most platforms occupies 64 bits. However, DO NOT HARD-CODE the type of integer you use throughout your code. You should be able to change only one line of code for your class to work with a different size integer (see the using statement on the second code line below). The code skeleton below gets you started, and also shows you the interface your class needs to implement. class Bits
using IType - unsigned long long; enum (NBITS = sizeof(IType) *8); I
Type bits = 0;
public: Bits() = default;
Bits (IType n) bits-n; 3 static int size() { return NBITS; 1
bool at (int pos) const; // Returns (tests) the bit at bit position pos
void set (int pos); // Sets the bit at position pos void set(); // Sets all bits
void reset (int pos); // Resets (makes zero) the bit at position pos
void reset(); // Resets all bits void assign(int pos, bool val); // Sets or resets the bit at position pos depending on val vois assign (IType n); // Replaces the underlying integer with n
void toggle (int pos); // Flips the bit at position pos void toggle(); // Flips all bits void shift (int n); // If n > 0, shifts bits right n places; if n <0, shifts left
void rotate (int n); // If n > 0, rotates right n places; if n <0, rotates left int ones () const; // Returns how many bits are set in the underlying integer int zeroes () const { // Returns how many bits are reset in the underlying integer return NBITS - ones(); } I Type to_int() const { return bits; } ); Also define the following non-member functions:
an output stream operator (<<) that prints the bits to an output stream (without a newline; hint: use std::bitset)
the equality operator =
the inequality operator != Remember that bit positions are numbered right-to-left, so bit position is the low order bit. "Rotate" means that bits that run off one end replace the vacated bits on the other.
Define all functions inline in a header file named bits.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:00
How can data be added in a table by using what view
Answers: 1
question
Computers and Technology, 22.06.2019 01:30
How will you cite information that is common knowledge in your research paper?
Answers: 1
question
Computers and Technology, 22.06.2019 07:50
In this lab, you complete a prewritten c++ program for a carpenter who creates personalized house signs. the program is supposed to compute the price of any sign a customer orders, based on the following facts: the charge for all signs is a minimum of $35.00. the first five letters or numbers are included in the minimum charge; there is a $4 charge for each additional character. if the sign is made of oak, add $20.00. no charge is added for pine. black or white characters are included in the minimum charge; there is an additional $15 charge for gold-leaf lettering. instructions ensure the file named housesign.cppis open in the code editor. you need to declare variables for the following, and initialize them where specified: a variable for the cost of the sign initialized to 0.00 (charge). a variable for the number of characters initialized to 8 (numchars). a variable for the color of the characters initialized to "gold" (color). a variable for the wood type initialized to "oak" (woodtype). write the rest of the program using assignment statements and ifstatements as appropriate. the output statements are written for you. execute the program by clicking the run button. your output should be: the charge for this sign is $82. this is the code, // housesign.cpp - this program calculates prices for custom made signs. #include #include using namespace std; int main() { // this is the work done in the housekeeping() function // declare and initialize variables here // charge for this sign // color of characters in sign // number of characters in sign // type of wood // this is the work done in the detailloop() function // write assignment and if statements here // this is the work done in the endofjob() function // output charge for this sign cout < < "the charge for this sign is $" < < charge < < endl; return(0); }
Answers: 1
question
Computers and Technology, 22.06.2019 16:20
It policy compliance and emerging technologies respond to the following: propose at least three control measures that organizations need to put in place to ensure that they remain complaint with emerging technologies and in a continually changing it environment. examine the correlation of effective configuration management and change control procedures to remain compliant with emerging technologies and it security changes.
Answers: 2
You know the right answer?
Define a class named Bits that holds a single integer variable. You will use this integer simply as...
Questions
question
Mathematics, 15.07.2020 01:01
question
English, 15.07.2020 01:01
question
Mathematics, 15.07.2020 01:01
question
History, 15.07.2020 01:01
Questions on the website: 13722359