Skip to content

Commit

Permalink
add argv namespace files
Browse files Browse the repository at this point in the history
  • Loading branch information
kugouming committed Sep 10, 2016
1 parent c720825 commit 4b9386b
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
11 changes: 11 additions & 0 deletions C++/argv.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <stdlib.h>
#include <iostream>
using namespace std;

//int main(int argc, const char * argv[])
int main(int argc, char * argv[])
{
cout << "argc count is:" << argc << endl;
cout << "argv value is:" << argv[0] << endl;
return 0;
}
65 changes: 65 additions & 0 deletions C++/namespace.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#include <stdlib.h>
#include <iostream>
using namespace std;

// 定义第一个命名空间
namespace stu
{
int x (100);
void fun()
{
cout << "hello world!!!" << endl;
}
}

// 定义第二个命名空间
namespace myNum
{
int x;
int y;

int setNum()
{
cout << "请输入整型:";
cin >> x >> y;

cout << "Y is:" << y << endl;

return x;
}
}

// 定义主入口
int main()
{
bool flag (false);
int b (10);
cout << flag << " == " << stu::x << endl;

stu::fun();

myNum::setNum();

bool isFlag = false;

if(myNum::x % 2 ==0)
{
isFlag = false;
}
else
{
isFlag = true;
}

if(isFlag)
{
cout << myNum::x << " 是奇数" << endl;
}
else
{
cout << myNum::x << " 是偶数" << endl;
}
return 0;
}

/* vim: set ts=4 sw=4 sts=4 tw=100 */

0 comments on commit 4b9386b

Please sign in to comment.