How the member's initial value like 'contents(ht * wd, c)' works in constructor function in C++ Primer? -


i have read book c++ primer. in section 7.3.1: there constructor of screen class:

class screen { public:     typedef std::string::size_type pos;     screen() = default;      screen(pos ht, pos wd, char c): height(ht), width(wd),                                      contents(ht * wd, c) { }     char get() const { return contents[cursor]; }      inline char get(pos ht, pos wd) const;     screen &move(pos r, pos c); private:     pos cursor = 0;     pos height = 0, width = 0;     std::string contents; }; 

and in overloaded constructor function:

screen(pos ht, pos wd, char c): height(ht), width(wd),                                  contents(ht * wd, c) { } 

what initial value of contents(ht * wd, c) , how works?
in section 7.1.4, there states:

the constructor initializer list of member names, each of followed member’s initial value in parentheses (or inside curly braces).

and have known string has way string s(n, 'c') initialize string such string s(10, 'c').
how works utilize string constructor in constructor member initialization?
in advance.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -