Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with the three short methods at the bottom, at() and set(pos)/set(). I don't quite understand how to implement the data structure; I can

Need help with the three short methods at the bottom, at() and set(pos)/set(). I don't quite understand how to implement the data structure; I can do the rest of the lab once I do.

image text in transcribed

(Sets = set as 1)

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}; IType bits = 0; public: Bits (0 = default; Bits (IType n) { bits = n; } static int size() { return NBITS; } 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

You can create a Pandas Index as its own object True False

Answered: 1 week ago

Question

1. Diagnose and solve a transfer of training problem.

Answered: 1 week ago