2. (Creating Object Adapters for Bitset, Compile-Time (Composition)) In this exercise we create a compile-time bit matrix
Question:
2. (Creating Object Adapters for Bitset, Compile-Time (Composition))
In this exercise we create a compile-time bit matrix (call it BitMatrix
The chosen data structure must be efficient (for example, accessing the elements).
Its interface must have the same look and feel as that of std::bitset<>.
We wish to reuse as much code as possible.
It must be generic enough to support a range of applications in different domains (for example, computer graphics and its many applications).
Answer the following questions:
a) Determine which data structure to use in order to implement BitMatrix
b) Constructors need to be created. Use the same defaults as with std::bitset
c) Implement the following operators for all rows in the matrix and for a given row in the matrix:
Set/reset all bits.
Flip the bits.
Test if none, all or any bits are set.
Access the elements.
Count the number of set bits.
d) Create member functions for OR, XOR and AND Boolean operations on bit matrices.
e) Consider creating the matrix as a derived class of bitset.
Step by Step Answer: