???????C++?е?struct??C?е?struct???????????????????????????????????????????????????????????????????
????struct??????????????   ???
????struct??????          ?????
????struct?????????       ???????
??????????????????????????????????????????棺
????1???????з???????struct??public???class??private???
????д???μ????
struct A
{
char a;
};
struct B : A
{
char b;
};
??????????B??public???A???????????????struct???class?????B??private???A????????????з???????????????????д???е?????????????д??
????struct B : public A
??????????????public??У?????????????private??С?
??????????????????public??л???private??У???????????????????????????struct??????class?????class???????struct??????????з????????????????????struct????class?????£?
????struct A{};
????class B : A{};    //private???
????struct C : B{};  //public???
????2??struct??????????????壬??????????????????public?????class????????????壬?????????????????????private
????3)“class”??????????????????????????“typename”?????????“struct”?????????????????
????4) ??????????????C++?е?struct???C?е?struct???????????????????????????C??struct??е???????????????????????д??
struct A    //???????struct
{
char c1;
int  n2;
double db3;
};
A a={'p'??7??3.1415926};  //??????????
????????struct???????????????{}???????
???????????struct?м?????????????????麯??????struct???????{}???????????????{}???????????????????????????б???????????а????????????????????д??A a={‘p’??7};??c1??n2???????????db3??С?????????copy???????????????????????????????÷??????????????????????????????麯?????struct????????????????????????{}??????????Ч?????????????????????????????????????????????仯??????????????????????????????{}??????á????????????????????????????????????????????????????????????????麯????????????????????????????д??????????
????????????????????????????struct????{}??????????????????????????????????Щ?????????????struct???????????????????????????????????????????????????struct???class??{}???????????????????????????????????——?????????????????????????????????struct???class??????????????public???private?????????????{}?????????????????public????????class???????{}?????struct????????????
???????????????????????????struct????????????????????????壬class??????????????????????塣
????????????????????????
????class??struct??????????????????????????????????г????
?????????ж??幹??????struct?????????????????
?????????ж??幹???????????г?????????public??????????????????????
?????????????????
????class?????????????????private?????struct??????public???
?????????з??
????class????????private??У???struct????????public??С?
??????????′?????????????????????????????
class T1
{
public:
void f()
{
cout<<"T1::f()"<<endl;
}
int x??y;
};
struct T2
{
int x;
void f(){cout<<"T2::f()"<<endl;}
};
struct TT1 : T1
{
};
class TT2 : T2
{
};
int main()
{
TT1 t1;
TT2 t2;
t1.f();
t2.f();
}
???????????
??????????У?????????????????class??typename????????struct?????岻???struct?????????“non-type template parameter”????class??typename??????????????????
????template <struct X>
????void f(X x)
????{
????}
????//?????????d:codecpptestcpptestcpptest.cpp(33) : error C2065: 'X' : undeclared identifier