#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 却链接错误呢?