C++类 单冒号
1.继承
class Base { }; class Derived : public Base { };
示列:
class Base
{
public:
int a=10;
};
class Derived : public Base
{
};
int main()
{
Derived b;
cout<<b.a<<endl;
}
2.访问控制
class MyClass { public: void public_member() { } private: void private_member() { } };
3.列表初始化
class MyClass { private: int member; public: MyClass() : member(0) { } };
4.位域
class MyClass { public: unsigned first : 1; unsigned second : 2; unsigned third : 4; };