為什么可以在結(jié)構(gòu)體里面聲明一個(gè)結(jié)構(gòu)體指針呢
#include<stdio>
struct weapon {
? ? int price;
? ? int atk;
? ? struct weapon * next;
};
int main(){
? ? struct weapon a, b, c, *head
#include<stdio>
struct weapon {
? ? int price;
? ? int atk;
? ? struct weapon * next;
};
int main(){
? ? struct weapon a, b, c, *head
2016-10-17
舉報(bào)
2016-10-17
你把struct weapon *p你把它換成int *p,你看懂嗎?定義struct類(lèi)型的地址,其實(shí)struct也是一種類(lèi)型了,C語(yǔ)言中給出了另一種構(gòu)造數(shù)據(jù)類(lèi)型——“結(jié)構(gòu)”,不能只有int啥的是類(lèi)型,struct也是類(lèi)型。
2017-01-05
因?yàn)檫@個(gè)指針指向的變量也是結(jié)構(gòu)體類(lèi)型的