在网上看到的源码 如str == "#Connected#",好多都是用##包围的是什么意思,求教

bool Chat::detectingInstruct(string str)
{

if(str == "#Connected#")
{
    if(isServer && RecSocket != NULL)
    {
        if(AllName.size() == 0)
        {
            RecSocket->SendData("#NoID#");
        }
        string newName = SetName();
        NameInRoom.push_back(newName);
        ShowName();
        Room->Send("#ClearNameInRoom##end#");
        for(vector<string>::iterator itr = NameInRoom.begin();
            itr != NameInRoom.end();itr++)
            Room->Send("#ShowName#" + *itr + "#end#");
        RecSocket->SendData("#GetName#" + newName + "#end#");
    }
    return true;
}
阅读 2.9k
2 个回答

其实你想多了..
"#Connected#" 就是 内容为 #Connected# 的字符串..
只是代码作者将 '#' 当做字符串的 开始符号和结束符号处理
或者说是 作者定 #command# ,这个格式是 是他定义的命令操作符
#begin# 开始
#end# 结束

这。。。首先允许我确认一下这是不是C++/CLI模式?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题