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

    你的配置有问题吧。

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败