结构体
把不同类型组合形成新的类型
struct 名字{
成员类型 成员名;
成员类型 成员名;
}
#include<iostream>
#include<string>
using namespace std;
struct Position{
float x;
float y;
float z;
};
struct Enemy
{
string name;
int hp;
int attack;
Position pos;
};
int main(){
/*float enemy1X;
float enemy1Y;
float enemy1Z;*/
Position enemy1Pos={100,20,90};
//enemy1Pos.x=90;
//enemy1Pos.y=10;
//enemy1Pos.z=12;
//cout<<enemy1Pos.y<<endl;
/*float enemy2X;
float enemy2Y;
float enemy2Z;*/
//Position enemy2Pos;
Enemy enemy1={"siki",100,50,{1,1,1}};
Enemy enemy2;
cout<<enemy1.pos.s<<endl;
return 0;
}