1.定义自己的命名空间myspace,并在myspace中定义一个字符串,并实现求字符串长度
#include <iostream>using namespace std;
namespace myspace {string str;int length_fun(){getline(cin,str);int i = 0;while(str[i] != '\0'){i++;}return i;}}
using namespace myspace;
int main()
{int len = length_fun();cout << "len= " << len << endl;return 0;
}
2.思维导图