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