为什么类可以从struct继承?
小子无知,近日看com的内容时发现一个我没见过的写法,就是类可以从struct继承,翻了不少书,里面都没有讲这个,所以来CSDN请教各位大牛,这种写法是怎么回事????我自己写了个代码如下:
struct X
{
X() { x = 0; }
int getx() { return x; }
int x;
};
class XA : public X
{
public:
XA() { y = 20; }
int gety() { return y; };
private:
int y;
};