When I want to use string::s(unsigned, char)
to assigned s
, the g++ output this error message.
There is my class:
#include <string>
using std::string;
class Screen()
{
private:
unsigned height = 0, width = 0;
string contents;
public:
Screen(unsigned ht, unsigned wd): height(ht), width(wd) {contents(ht * wd, ‘ ’);}
}
Why it is wrong?
I know that it should be Screen(unsigned ht, unsigned wd): height(ht), width(wd), contents(ht * wd, ‘ ’){ }
, but why I can't use the functionstring(unsigned, char)
to assigned a value for a string constructed?
Aucun commentaire:
Enregistrer un commentaire