int main()
{
typedef struct a
{
static int w;
char *p;
} a;
}
上編譯它給error:expected specifier-qualifier-list before 'static'
可以ü請告訴我這是什麼錯誤的手段,以及如何去除呢?編譯器錯誤:「預期說明符限定符列表」
int main()
{
typedef struct a
{
static int w;
char *p;
} a;
}
上編譯它給error:expected specifier-qualifier-list before 'static'
可以ü請告訴我這是什麼錯誤的手段,以及如何去除呢?編譯器錯誤:「預期說明符限定符列表」
本地類在C++中不能有靜態數據成員。
引述標準(第9.8.4)
A local class shall not have static data members.
在你不知道的可能性不大的情況下,局部類是一個類,結構或功能範圍定義的工會。
9.8.1
A class can be defined within a function definition; such a class is called a local class.
static
是存儲類,所以它不會正確地應用到typedef
。它與register
和const
相同。
即使static
工作,w
將如何靜態和p
不是靜態的?
這會的工作,雖然:
int main()
{
typedef struct a
{
int w;
char *p;
} a;
static a a0;
}
是什麼,但關於C? –
@Shashi Bhushan:C不支持靜態數據成員。 –
@Shashi:我已經從你的問題中刪除了C標籤,因爲你的main()聲明不是C. –