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

假设所有代码均已引入所需头文件(iostream、string),且使用using namespace std; 编译环境符合C++11及以上标准。

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