效果:相等为1,不等为0
/*功能:名字命名空间日期:2013-09-12*/
#include<iostream>#include <string>
using std::endl;using std::cout;
namespace equalSting{ bool isEqual(char *p,char *q) { if (strcmp(p,q)) { return 0; } else { return 1; } }}
namespace equalInt{ bool isEqual(int x,int y) { if ( x == y ) { return 1; } else { return 0; } }}
int main(void){ char *p = "abc"; char *q = "abc"; bool boo = equalSting::isEqual(p,q); cout << boo << endl;
p = "abd"; q = "abc"; boo = equalSting::isEqual(p,q); cout << boo << endl;
int x = 2 , y = 2; boo = equalInt::isEqual(x,y); cout<<boo<<endl;
system("pause"); return 0;
}
评论