Files
BasicsOfComputerSoftwareEng…/OOP/15Exam/3.1.cpp
2023-05-30 19:37:18 +08:00

36 lines
545 B
C++

#include <iostream>
using namespace std;
int Num = 1;
namespace Name1 {
int Num = 2;
int Add(int Num) {
Num = ::Num + Num;
return Num;
}
} // namespace Name1
namespace Name2 {
int Num = 3;
int Add(int Num) {
Num = ::Num + Num;
return Num;
}
} // namespace Name2
int main() {
cout << Name1::Add(4) + ::Num << endl;
cout << Name2::Add(5) + Num << endl;
namespace N2 = Name1;
cout << N2::Add(6) + N2::Num << endl;
using namespace Name2;
cout << Add(7) + Name2::Num << endl;
return 0;
}
/*
6
7
9
11
*/