六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 15|回复: 0

C++之Namespace使用源代码

[复制链接]

升级  81.33%

142

主题

142

主题

142

主题

举人

Rank: 3Rank: 3

积分
444
 楼主| 发表于 2013-2-4 19:50:11 | 显示全部楼层 |阅读模式
// myspace.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>using namespace std;namespace A{string str = "hello, andylin!";void fun1(int nVal){cout << nVal << endl;}void fun2(string str){cout << str.c_str() << endl;}}namespace B{string str = "hello, baby!";void fun1(int nVal){cout << -nVal << endl;}void fun2(string str){ string strTemp(str.rbegin(), str.rend());cout << strTemp.c_str() << endl;}}int _tmain(int argc, _TCHAR* argv[]){A::fun1(123);B::fun1(123);A::fun2(B::str);B::fun2(A::str);return 0;}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表