q274989079 2015-04-09 15:59 采纳率: 33.3%
浏览 1736

一段代码编译的问题!CCC CLang Visual C++

 #include <string>
#include <iostream>

class Paser
{
    public:

        Paser ( std::string _Command );

        std::string Root ( );
        /**std::string Operator ( );

        std::string Path1 ( );
        std::string Path2 ( );

        std::string Variable ( );**/

    private:

        std::string Command;
        std::string CommandReturn;

        void CommandSync ( );

};

int main()
{
    Paser Paserd ( "move /a/b/c/d /ca/b/cd/" );

    std::cout << Paserd.Root ( ) << '\n';

    return 0;
}


Paser::Paser ( std::string Command )
{
    Paser::Command = Command;
}

std::string Paser::Root ( )
{

    Paser::CommandSync ( );

    if ( Command.empty ( ) )
    {
        throw 1;
    }
    else if ( Command.find ( " " ) == std::string::npos )
    {
        throw 1;
    }
    else 
    {
        return CommandReturn.substr ( 0 , CommandReturn.find ( " " ) );
    }
}

void Paser::CommandSync ( )
{
    CommandReturn = Command;
}

此代码在 Windows下正常编译并可以运行,为何在 Linux下 用 GCC 和 Clang 却链接错误呢?

  • 写回答

2条回答

  • threenewbee 2015-04-09 16:41
    关注

    http://codepad.org/PyweSdtd
    GCC 4.9.2在线正确编译,输出move

    你的配置有问题吧。

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?