1.C++的結(jié)構(gòu)體變量在聲明的時(shí)候可以省略struct,在c中這樣是不可以的,例子如下
#include<iostream>#include<string>using namespace std;struct test{ int num; string name;};int main(void){ test t; t.num=1; t.name="jack"; cout<<t.num<<" "<<t.name<<endl; } 2.c++的結(jié)構(gòu)體聲明可以聲明在main()函數(shù)中,也可以在main()函數(shù)之前,在之前的話,整個(gè)程序都可以調(diào)用,這也是最常用的方式;而在內(nèi)部的話,只能在函數(shù)內(nèi)使用,也就是說(shuō)在聲明的函數(shù)內(nèi)可以使用,類(lèi)似于局部變量的概念。如下
int main(void){ struct test{ int num; }; test hello;//right }void t(){ test t; //wrong} 


















