This excercise is from C++ primer 5th edition.
I have not understood everything about constructors, mainly about how they function.
Work prior to the excercise was creating a class called screen with some specifications.
This is the class:
The excercise goes as follows:Code:class screen{ public: using pos = string::size_type; screen() = default; private: pos height = 0; pos width = 0; pos cursor = 0; string contents; };
Excercise 7.24: Give your Screen class three constructors: a defaultconstructor; a constructor that takes values for height and width and initializes the contents to hold the given number of blanks; and a constructor that takes values for height, width, and a character to use as the contents of the screen.
Giving the screen a default constructor was easy. The next part is probably easy aswell, I just dont understand what they mean when they say "and initalize the contents to hold the given number of blanks" and something in the 3rd part when they say "character to use as the contents of the screen". If anyone of you guys could explain it to me, it would make my day!
Edit: Think I have made a breakthrough... Would the constructor for the second part look like this:
screen(pos ht, pos wd) : contents(ht*wd) {}
or something?