一段代码编译的问题!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 却链接错误呢?

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

你的配置有问题吧。

链接错误是你的编译器选项中没有包含对应类库,-L选项