SizeType由string类类型和vector类类型定义的类型,用以保存任意string对象或vector对象的长度,标准库类型将size_type定义为unsigned类型
class Screen
{
public:
Screen(void);
~Screen(void);
typedef string::size_type pos;
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);
//using pos = string::size_type;
private:
pos cursor;
pos width;
pos height;
string contents;
};
inline Screen& Screen::move(pos r,pos c)
{
pos row = r*width;
cursor = row +c;
return *this;
}
char Screen::get(pos r,pos c)const
{
pos row = r*width;
return contents[row+c];
}