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]; }
相关文章推荐
- C++对象内存模型(堆栈模型)
- c语言位段
- 北大ACM作业练习 1001
- 北大ACM作业练习 1001
- c++ 常用代码片段
- MD5 C++源码
- c++ primer 学习笔记-第四章
- C语言详解+例子2
- C++ 虚函数表解析
- 把vim打造成牛逼的C++ IDE
- C语言:十进制进制转换为其他进制(思想:查表法)
- C语言:其他进制转换为十进制(方法二)
- C语言:其他进制数转换为十进制(方法一)
- Cinatra:高性能现代C++ Web框架
- C语言深度解剖——读书笔记-6、预处理
- 刚开始学:C语言 BubbleSort冒泡排序算法
- C++类基础代码
- C++调用C#库简单例程
- C语言:顺序结构(数组)栈
- C++ sort()