#include
#include
using namespace std;
struct MyStruct
{
int number;
string name;
};
MyStruct my_struct = { 21032114, "李威涛" }; //直接初始化
int main()
{
cout << my_struct.name << endl;
}
`#include
#include
using namespace std;
struct MyStruct
{
int number;
string name;
};
int main()
{
MyStruct my_struct; //逐个赋值法
my_struct.name = "李威涛";
cout << my_struct.name << endl;
}