Câu 62: CPP: C++ Certified Professional Programmer
What happens when you attempt to compile and run the following code?#include #include using namespace std;template class A {T_v;public:A() {}A(T v): _v(v){}T getV() { return _v; }void add(T & a) { _v+=a; }void add(string & a) {_v.insert(0, a);}};int main(){A a("Hello");string s(" world!");a.add(s);cout << a.getV() <<e…
Nội dung câu hỏi
What happens when you attempt to compile and run the following code?#include #include using namespace std;template class A {T_v;public:A() {}A(T v): _v(v){}T getV() { return _v; }void add(T & a) { _v+=a; }void add(string & a) {_v.insert(0, a);}};int main(){A a("Hello");string s(" world!");a.add(s);cout << a.getV() <<endl;return 0;}
Các lựa chọn
Đáp án được giữ gọn theo nhãn A, B, C, D trong phần bình chọn tương tác.
- A. program will display: Hello world!
- B. compilation error — đáp án hiện tại
- C. program will display: world!Hello
- D. program will run without any output
Cộng đồng
0 bình luận công khai. Tên thành viên được ẩn một phần.