class Screen
{
public:
typedef std::string::size_type index;
Screen():contents("Start:"),cursor(0),height(0),width(0){}
Screen(string s,index p,index h,index w):contents(s),cursor(p),height(h),width(w){}
~Screen(){}
index get_cursor();
Screen& move(index r,index c);
Screen& setPos(char);
Screen& setPos(index,index,char);
void print();
private:
std::string contents;
index cursor;
index height,width;
};
Screen& Screen::setPos(char c)
{
contents[cursor]=c;
return *this;
}
Screen& Screen::move(index r,index c)
{
index row=r*width;
cursor=row*c;
return *this;
}
index Screen::get_cursor()
{
return cursor;
}
void Screen::print()
{
cout<<"Position row and column are "<<height<<" and "<<width<<"."<<endl;
cout<<"String is "<<contents<<"."<<endl;
}
void main()
{
Screen face;
face.move(10,5).setPos('#').print();
int pos=face.get_cursor();
cout<<"cursor pos is "<<pos<<" ."<<endl;
}