65,186
社区成员




#include <string>
class Screen {
public:
using pos = std::string::size_type;
Screen() = default;
Screen(pos ht, pos wd) :height(ht), width(wd), contents(ht*wd, ' ') { }//这里contents过了
char get() const { return contents[cursor]; }
char get(pos r, pos c) const { return contents[r*width + c]; }
std::string re(std::istream &is)
{
std::string rtn;
char content;
pos height=0, width=0;
is >> height >> width >> content;
return rtn(height*width, content);//这里报错,貌似是string的初始化问题,格式和上面的contents一样但过不了编译,不知道为什么。
}
private:
pos cursor = 0;
pos height = 0, width = 0;
std::string contents;
};
return std::string(height*width, content);