首页 > 编程语言 > 详细

【c++ primer, 5e】类的其他特性

时间:2017-04-12 19:49:50      阅读:132      评论:0      收藏:0      [点我收藏+]

类成员再探

定义一个类型成员:

#include <iostream>
#include <string>

using namespace std;
class Screen {
public:
    using pos = string::size_type;
    /*
        这就是“类型成员”,必须先定义后使用(p232)
        等价声明: typedef string::size_type pos;
        string::size_type 一般是 unsigned int
    */
private:
    pos cursor = 0; // 光标的位置
    pos height = 0, width = 0; // 屏幕的高和宽
    string contents; // 保存内容
};

int main()
{
    return 0;
}

 

返回*this的成员函数

类类型

友员再探

 

【c++ primer, 5e】类的其他特性

原文:http://www.cnblogs.com/xkxf/p/6700751.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!