静态成员可以是不完全类型

来源:互联网 发布:单片机延时1s程序 编辑:程序博客网 时间:2024/05/29 09:07
class Student{    static Student s;    //Student ss;//错误,不允许使用不完整类型    Student *sss;//不完整类型可以是指针或引用    Student &ssss;};

静态成员的初始化问题

class Example{public:    static double rate = 6.5;//错误,静态成员不能在类中初始化    static const int v = 10;//正确,只有整型静态常量才能在类中初始化    int i = 10;//最好不要这样做    static const double x = 1.0;//错误,只有整型静态常量才能在类中初始化}
0 0
原创粉丝点击