// ============================================================================ // p1c03_09 — 3.2.2命名空间使用语法 // 来源:川大 C++/LinuxC wiki「02.Qt方向」 // 说明:本文件由 gen_part1.py 合并页面中的教学片段而成。每个片段用 // // --- 原文片段 [pageId:blockIdx] --- 标注出处。 // 已做最小修正(笔误/平台移植),详见 docs/ERRATA.md。 // ============================================================================ #include using namespace std; // --- 原文片段 [58954439:8] 3.2.2命名空间使用语法 --- namespace{ int a = 10; void func(){ cout << "hello namespace" << endl; } } void test(){ cout << "a : " << a << endl; func(); } // --- main --- int main() { test(); return 0; }