MS VC2010 コンパイラを使用して最初の作業を行うクロス プラットフォーム コード ベースを開発しています。その後、GCC (4.7) を使用して Linux でコンパイルします。
「呼び出しに一致する関数がありません..」 GCC のエラー。メソッド パラメーターが非定数参照である場合に主に問題が発生することに気付きました。たとえば、次のようになります。
void MyClass::DoSomeWork(ObjectSP &sprt, const std::string someName, const std::string anotherName, const std::string path, int index) {
sprt->GetProp()->Update(path, false);
}
メソッドをこれに変更したら:
void MyClass::DoSomeWork(const ObjectSP& sprt, const std::string& someName, const std::string& anotherName, const std::string& path, int index) {
sprt->GetProp()->Update(path, false);
}
GCC は不平を言うのをやめます。VC コンパイラでなぜ発生し、なぜ発生しないのですか?