0

最初の小さなコード:

class CDb
{
public:
    void CreateLeague(const League &data);
protected:
    int InsertOwners(const std::vector<std::string> &owners, int leagueId);
};

void CDb::CreateLeague(const League &data)
{
    // some code 
    if( InsertOwners( data.GetOwners(), leagueId ) != SQLITE_OK )
    {
      // ROLLBACK transaction
    }
}

int CDb::InsertOwners(const std::vector<std::string> &owners, int leagueId)
{
}

関数GetOwners()は次のように宣言されます:

std::vector<std::string> &GetOwners() const;

リンク中に私は次のようになります:

未解決の外部シンボル"protected:int __thiscall CDb :: InsertOwners(class std :: vector、class std :: allocator>、class std :: allocator、class std :: allocator >>> const&、int)"(?InsertOwners @ CDb @@ IAEHABV?$ vector @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@ V?$ allocator @ V?$ basic_string @ DU?$ char_traits @ D @ std @@ V?$ allocator @ D @ 2 @@ std @@@ 2 @@ std @@ H @ Z)関数 "public:void __thiscall CDb :: CreateLeague(class CLeagueSettings const&)"( ?CreateLeague @ CDb @@ QAEXABVCLeagueSettings @@@ Z)1> vc_mswud \ baseballdraft.exe:致命的なエラーLNK1120:1つの未解決の外部

Windows7でMSVC2010を使用する。

助けてください。

4

2 に答える 2

0

コードスニペットを見て明確な解決策を提供するのは困難です。

「データ」タイプとは何ですか?

アプリと暗黙的にリンクしているライブラリを使用しているのではないかと思います。データの型と関数のすべての宣言がありますが、.libモジュールとリンクしていないため、GetOwnersの実装が表示されず、リンカーが悲鳴を上げます。

もう1つの可能性は、データ型(クラス?)が宣言されているが、実装ファイル(cpp)がプロジェクトに含まれていないため、data.GetOwners()が上記と同じ理由でリンカーエラーを引き起こすことです。実装が表示されません。

于 2012-10-13T14:06:17.270 に答える
0

次のコードがコンパイルされることを確認します。

int CDb::InsertOwners(const std::vector<std::string> &owners, int leagueId) 
{ 
} 

これが別のソース ファイル (.CPP) に含まれているかどうか、およびその特定のファイルがプロジェクトに含まれているかどうかを確認します。これが実際のコードである場合、returnステートメントが欠落しているため、エラーが発生します。

于 2012-10-12T08:10:06.043 に答える