第29424题 单选题
将以下哪个选项的代码片段插入到给定C++代码的main函数空白处,可以正确编译并运行?
#include <iostream>
#include <string>
using namespace std;

template <typename T>
struct TestStruct {
    T data;
    void show() {
        cout << data << endl;
    }
};

int main() {
    // 此处插入选项代码片段
}
A

TestStruct s; s.data = 10; s.show();

B

TestStruct<int> si; si.data = 100; si.show();

C

TestStruct<double> td; TestStruct<double>::show();

D

TestStruct<string> ts; show();

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析