Question: Please solve all my doubts (a) Using C++'s Standard Template Library vector class template, define the private data and public interface of an Image class

Please solve all my doubts
Please solve all my doubts (a) Using C++'s Standard Template Library vector
class template, define the private data and public interface of an Image
class in which each pixel is a single byte (in C++ this

(a) Using C++'s Standard Template Library vector class template, define the private data and public interface of an Image class in which each pixel is a single byte (in C++ this is an unsigned char). Hint: the private data will need to store the image data itself and you could either use a vector of vectors of unsigned chars for this, or a single flat vector of unsigned chars; it will also need the height and width of the image; the interface will need methods to get and store pixel data, etc; the constructor should take the height and width as arguments and create the pixel data. (b) How could you change your class so that it could store a real number per pixel instead (i.e. double)? a 1 why use unsigned char 2 3 4 why 5 6 17 8 0 6 class Image { GI: public: Q3 : Image (int w, int h); use void? unsigned char GetPixel (int x, int y); void Set Pixel (int x, int y, unsigned char val); int GetHeight(); int GetWidth(); Q2:3 why input this? private : vector > pixels; int width; int height; 04: Why 2 sets of ca }; Image:: Image (int w, int h) : width(w), height (h) { pixels.resize(height); for (int i=0; i class Image { Data Type here? public: Image (int w, int h); DataType GetPixel(int x, int y); void SetPixel (int x, int y, DataType val); int GetHeight(); int GetWidth(); private: vector > pixel; int width; int height; 17 8 19 10 11 12 13 14 }; 16 Listing 11: Templated Image

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Lets go through each part to address your questions and doubts a Define Image Class using unsigned char Why use unsigned char An unsigned char can rep... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!