除了定义数据和函数成员之外,类还可以定义自己的局部类型名字.如果为std::string::size_type提供一个类型别名,那么Screen类将是一个更好的抽象:
class Screen{
public:
typedef std::string::size_type index;
private:
std::string contents;
index cursor;
index height, width;
}
在哪都能用的 Screen::index 这样就行了;