第30955题 单选题
以下关于C++结构体的语法使用,正确的是?

假设代码中已引入<iostream><string>头文件,且使用了using namespace std;,以下代码片段语法正确的是?

A
struct Student {
    int id;
    string name;
}
Student s;
s.id = 1001;
B
struct Student {
    int id;
    string name;
};
Student *s = new Student;
s.id = 1002;
C
struct Student {
    int id;
    string name;
};
Student s = {1003, "张三"};
cout << s.name;
D
struct {
    int id;
    string name;
} Student;
Student s;
s.id = 1004;
程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析