#include<iostream>
#include<string>
using namespace std;
enum Level{a,b,c,d};
class student{
static int counting;
Level level:2; 2--》二进制位 位域:人工分配内存空间大小,实现内存使用最小化
public :
void showing();
student(Level level):level(level){ counting++;}
static void showingcount();
void showing()const;
};
int student::counting=0;
void student::showingcount()
{
cout<<"give you a total number:"<<counting<<endl;
}
void student::showing()
{
switch (level)
{
case a:
cout<<'a';
break;
case b:
cout<<'b';
break;
case c:
cout<<'c';
break;
case d:
cout<<'d';
break;
}
cout<<" 非const函数调用 student number:"<<counting<<endl;
}
void student::showing() const
{
switch (level)
{
case a:
cout<<'a';
break;
case b:
cout<<'b';
break;
case c:
cout<<'c';
break;
case d:
cout<<'d';
break;
}
cout<<" const 函数调用 student number:"<<counting<<endl;
}
int main(void)
{
student one(b);
one.showing();
student oneone(a);
oneone.showing();
student::showingcount();
const student opener(c);
opener.showing();
cout<<endl<<"the size of student:"<<sizeof(student)<<endl;
return 0;
}