📄 04_01.cpp
字号:
// 04_01.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
namespace ns1{ // 名字空间域ns1
class matrix{ // 类域ns1::matrix
int size;
public:
void SetSize(int size){ matrix::size = size + 10;}
int GetSize(){ return size; }
};
};
namespace ns2{ // 名字空间域ns2
class matrix{ // 类域ns2::matrix
int size;
public:
void SetSize(int size){ matrix::size = size; }
int GetSize(){ return size; }
};
};
ns1::matrix m; // 全局域中定义变量m,变量类型为ns1::matrix
int main(int argc, char* argv[])
{
ns2::matrix m; // 局部域中定义变量m,变量类型为ns2::matrix
m.SetSize(10); // 局部域中的m
::m.SetSize(10); // 全局域中的m
printf("\n size = %d", m.GetSize());
printf("\n size = %d", ::m.GetSize());
getch();
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -