Câu hỏi:

28/07/2025 165 Lưu

In the following code what would be the values of i1 and i2

#include <iostream>

using namespace std; namespace N1 { int f(int n) { return n * 2; } } namespace N2 { int f(double n) { return n * 3; } } void main() { using N1::f; int i1 = f(1.0); cout << "i1 = " << i1; using N2::f; int i2 = f(1.0); cout << "i1 = " << i2; system("pause"); }

A. i1=2 i2=2

B. i1=2 i2=3

C. i1=3 i2=2

D. Error

Quảng cáo

Trả lời:

verified Giải bởi Vietjack

Chọn đáp án B

CÂU HỎI HOT CÙNG CHỦ ĐỀ

Lời giải

Chọn đáp án B

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP

Câu 5

A. Have wine and cheese with that other friend

B. Allow that class to declare an instance of it in its list of private variables

C. Allow the other class (the one declared as friend) to access to the declaring class’s private variables

D. Allow the class declaring the other as a friend to access the declared class’s private variables

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP

Lời giải

Bạn cần đăng ký gói VIP ( giá chỉ từ 250K ) để làm bài, xem đáp án và lời giải chi tiết không giới hạn.

Nâng cấp VIP