[英]c++ class members outside access specifiers
I am not really firm with C++ yet and learning by reading example code. 我对C ++还不是很坚定,而是通过阅读示例代码来学习。 I now found a class declaration, that has member variables outside the access specifiers public and private.
现在,我发现了一个类声明,该类声明的成员变量在访问说明符public和private之外。
class Card {
friend class FortyApp;
static double m_scale;
static int m_width,m_height;
public:
Card(int value, WayUp way_up = facedown);
virtual ~Card(){};
void Draw(wxDC& pDC, int x, int y);
static void DrawNullCard(wxDC& pDC, int x, int y); // Draw card place-holder
void Erase(wxDC& pDC, int x, int y);
void TurnCard(WayUp way_up = faceup) { m_wayUp = way_up; }
WayUp GetWayUp() const { return m_wayUp; }
int GetPipValue() const { return m_pipValue; }
Suit GetSuit() const { return m_suit; }
SuitColour GetColour() const { return m_colour; }
static void SetScale(double scale);
static int GetHeight() { return m_height; };
static int GetWidth() { return m_width; };
static double GetScale() { return m_scale; };
private:
Suit m_suit;
int m_pipValue; // in the range 1 (Ace) to 13 (King)
SuitColour m_colour; // red or black
bool m_status;
WayUp m_wayUp;
static wxBitmap* m_symbolBmap;
static wxBitmap* m_pictureBmap;
};
I don't understand if this has a higher reason. 我不知道这是否有更高的理由。 The variables m_scale, m_width and m_height are now private, as it is standard, or?
变量m_scale,m_width和m_height现在是私有的,因为它是标准变量,还是?
Thanks in advance. 提前致谢。
do you know the default access specifier is ? 您知道默认的访问说明符是吗?
it is private . 它是私人的 。
if you don't provide any access specifier it will be automatically set to private . 如果您不提供任何访问说明符,它将自动设置为private。
if you want to M_scale
to be public declare it inside public:
如果要使
M_scale
公开,请在public:
内部声明public:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.