typedef struct


#include<iostream>
#include<queue>
using namespace std;

 typedef struct node
{
	int x;
	int y;
	node(int xx, int yy){
		x = xx;
		y = yy; 
	}	
}ha;//加上typedef后是類型,不是變量

struct no{
	int x;
	int y;
	
}thisisvariable; //不加是變量 
 
int main(){
     ha a=node(1,2);
     cout<<a.x;
    ha.x=1;//這個報錯了 
	 thisisvariable.y=3;
//	 cout<<ha.x;
	 cout<<thisisvariable.y;
	return 0;
}

typedef 的報錯了,而不加typedef的沒有報錯,雖然也能輸入.然后又里面的變量,但是是有錯的

注釋掉node函數之后是可以只定義不賦值的

加上就不能只定義必須要賦值

賦值后就可以運行


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM