Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1.1 You are asked to implement a C++ class to model an array of bits of arbitrary size. The idea is that we want to

image text in transcribed

1.1 You are asked to implement a C++ class to model an array of bits of arbitrary size. The idea is that we want to store n bits and want to make sure that we do not waste storage and each bit occupies exactly one bit of memory. This is because the class is to be used in an embedded application that cannot assume the presence of the STL and must also use the smallest amount of storage possible. Your class should offer an API that enables looking up and setting the value of a bit (for example, x.getValue(25) would return the value of the 25th bit, and x.setValue (25,1) would set its value to 1 ). You should also provide appropriate constructors, destructor, and member function printArray which prints only bit indices which have the value of 1 . You are also asked to implement a main program that uses your class demonstrate the above interfaces and functionality. 1.2 You are asked to build on your work in (1.1) to provide the index operator ([]] to enable accessing specific bits in your array. For example, to enable code like: {// BitArray b(40); cout b.getValue(25); // prints the value of the bit at index 25 cout b[25];// also prints the value of the bit at index 25 // ... \} Please provide a test program to demonstrate that your class and operators behaves as expected and handles errors in an appropriate manner

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Principles Of Database Systems With Internet And Java Applications

Authors: Greg Riccardi

1st Edition

020161247X, 978-0201612479

More Books

Students also viewed these Databases questions

Question

What qualities do you see as necessary for your line of work?

Answered: 1 week ago