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, 22.06.2019 18:30
Kto rozmawia z clamentain przez krótkofalówke w the walking dead w 4 epizodzie
Answers: 1
question
Computers and Technology, 22.06.2019 20:30
In this lab, you complete a prewritten c program that calculates an employee’s productivity bonus and prints the employee’s name and bonus. bonuses are calculated based on an employee’s productivity score as shown below. a productivity score is calculated by first dividing an employee’s transactions dollar value by the number of transactions and then dividing the result by the number of shifts worked.
Answers: 3
question
Computers and Technology, 23.06.2019 04:31
Q14 what is most important for you to choose before you build a network? a. private network b. nos c. network media d. network protocol e. directory service
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
Auser is given read permission to a file stored on an ntfs-formatted volume. the file is then copied to a folder on the same ntfs-formatted volume where the user has been given full control permission for that folder. when the user logs on to the computer holding the file and accesses its new location via a drive letter, what is the user's effective permission to the file? a. read b. full control c. no access d. modify e. none of the above
Answers: 1
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, 18.03.2021 01:20
question
Social Studies, 18.03.2021 01:20
question
Mathematics, 18.03.2021 01:20
question
Mathematics, 18.03.2021 01:20
Questions on the website: 13722360