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函数之后是可以只定义不赋值的

加上就不能只定义必须要赋值


浙公网安备 33010602011771号