您的位置:首页 > 编程语言 > C语言/C++

C++内联函数

2015-08-02 12:46 513 查看
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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: