class Line{ Line( int len ); // 建構式 Line( const Line &obj); // 拷貝建構式 ~Line(); // 解構式}
兒子不能用Private,朋友可以
class Ball;int compare(Ball&, Ball&);class Ball { public: .... // 宣告朋友類別 friend class SomeClass; // 宣告朋友函式 friend int compare(Ball&, Ball&);private: ....};
friend int compare(Ball&, Ball&);
const int value; //value是const,value不可變int const value; //value是const,value不可變
const int* Content; //指標(Content)可變,指標指到的內容(*Content)不可變 int* const Content…
(Global變數最好是有明確理由才使用)
Static關鍵字主要描述的是「可視範圍」和「變數週期」
Static Storage有三種使用方式
用來當作別名
class A { public: A() : _n(1) { } protected: int _n; }; class B : public A { public: B() : _m(_n) { } private: int _m; };