1struct的成员默认权限是public,而class的成员默认权限是private。
#include <iostream>
int main()
{
class A
{
public:
int a;
};
struct B
{
public:
int a;
};
A A1;
B B1;
B1.a = 0;
A1.a = 0;
return 0;
}
2.struct的默认继承方式为public,而class的默认继承为private
#include <iostream>
int main()
{
class A
{
public:
int a;
};
struct B
{
public:
int a;
};
class A1:A
{
};
struct B1:B
{
};
B1 B2;
A1 A2;
A2.a = 0;
B2.a = 0;
return 0;
}