命名空间namespace的用法

// ceshi.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "iostream"
#include "opencv2/opencv.hpp"
using namespace std;
namespace savitch1
{
void savitch1_greeting()
{
cout<<"Hello from namespace savitch1."<<endl;
}
}
namespace savitch2
{
void savitch2_greeting()
{
cout<<"Hello from namespace savitch2."<<endl;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
savitch1::savitch1_greeting();
savitch2::savitch2_greeting();

/*下面的就是红色部分所代表的意思

{

  using namespace savitch1;

  savitch1_greeting();

}

{

  using namespace savitch2;

  savitch2_greeting();

}

*/
cvWaitKey();
return 0;
}

 

posted @ 2014-09-22 21:00  龙泽一狼  阅读(94)  评论(0编辑  收藏  举报