こんにちは、私は単純なC++プログラムを作ったが、私はエラーが発生していると私は間違って何をしているのか分からない。私はC++構文が新ですので、間違ったリンカーエラーを引き起こしている間違いを理解できません。LNK2019:未定義の外部シンボル 'シンボル'が関数 'function'で参照されています。致命的なエラーLNK1120:1解決されていない外部
ITest.h
#ifndef ITest_H
#define ITest_H
//#[ ignore
#ifdef _MSC_VER
// disable Microsoft compiler warning (debug information truncated)
#pragma warning(disable: 4786)
#endif
//#]
//## auto_generated
#include <string>
//## auto_generated
#include <algorithm>
//## auto_generated
//## link itsNmNeighborhoodEntry
class NmNeighborhoodEntry;
//## class ITest
class ITest {
//#[ ignore
//// Constructors and destructors ////
public :
//## auto_generated
virtual ~ITest();
//// Relations and components ////
protected :
NmNeighborhoodEntry* itsNmNeighborhoodEntry; //## link itsNmNeighborhoodEntry
};
#endif
ITest.cpp
//## auto_generated
#include "ITest.h"
//## link itsNmNeighborhoodEntry
#include "NmNeighborhoodEntry.h"
//## class ITest
ITest::~ITest() {
}
Test1.h
#ifndef Test1_H
#define Test1_H
//#[ ignore
#ifdef _MSC_VER
// disable Microsoft compiler warning (debug information truncated)
#pragma warning(disable: 4786)
#endif
//#]
//## auto_generated
#include <string>
//## auto_generated
#include <algorithm>
//## class Test1
#include "ITest.h"
//## auto_generated
class NmNeighborhoodEntry;
//## class Test1
class Test1 : public ITest {
//#[ ignore
// Default Constructor is Private
public:
Test1();
// Default Copy Constructor is Private
private:
Test1(const Test1& self);
// Default Assignment Operator is Private
private:
Test1& operator=(const Test1& aTest1);
//#]
//// Constructors and destructors ////
public :
//## auto_generated
~Test1();
NmNeighborhoodEntry* getNmNeighborhoodEntry();
};
#endif
Test1.cpp
//## auto_generated
#include "Test1.h"
//## auto_generated
#include "NmNeighborhoodEntry.h"
NmNeighborhoodEntry* itsNmNeighborhoodEntry;
//## class Test1
Test1::~Test1() {
}
Test1::Test1() {
}
NmNeighborhoodEntry* getNmNeighborhoodEntry() {
//return itsNmNeighborhoodEntry;
return NULL;
}
:ここでこのエラーを生成サンプルコードであります
NmNeighborhoodEntry.h
#ifndef NmNeighborhoodEntry_H
#define NmNeighborhoodEntry_H
//#[ ignore
#ifdef _MSC_VER
// disable Microsoft compiler warning (debug information truncated)
#pragma warning(disable: 4786)
#endif
//#]
//## auto_generated
#include <string>
//## auto_generated
#include <algorithm>
//## class NmNeighborhoodEntry
class NmNeighborhoodEntry {
//#[ ignore
// Default Constructor is Private
private:
NmNeighborhoodEntry();
// Default Copy Constructor is Private
private:
NmNeighborhoodEntry(const NmNeighborhoodEntry& self);
// Default Assignment Operator is Private
private:
NmNeighborhoodEntry& operator=(const NmNeighborhoodEntry& aNmNeighborhoodEntry);
//#]
//// Constructors and destructors ////
public :
//## auto_generated
~NmNeighborhoodEntry();
bool myIsPending; //## attribute myIsPending
unsigned short index; //## attribute myNodeIndex
};
#endif
NmNeighborhoodEntry.cpp
//## auto_generated
#include "NmNeighborhoodEntry.h"
//## class NmNeighborhoodEntry
NmNeighborhoodEntry::~NmNeighborhoodEntry() {
}
driver.cpp
//#include "ITest.h"
#include "Test1.h"
//#include "Test2.h"
#include "NmNeighborhoodEntry.h"
Test1 *test1;
//Test2 *test2;
NmNeighborhoodEntry* myNmNeighborhoodEntry;
void main() {
test1 = new Test1;
//test2 = new Test2;
//test1->itsNmNeighborhoodEntry = NULL;
myNmNeighborhoodEntry = test1->getNmNeighborhoodEntry();
}
一般的には、何かを宣言して使用しましたが、定義していないことを意味します。しかし、私はあなたが本当にあなたが得ると言っている正確なエラーを取得しているとは思わない。 –
メンバー関数を持つクラスを宣言する3つのヘッダーを表示します。あなたは、(いくつかの)メンバーを実装する1つのファイルのみを表示します。残りはどこにありますか?リンカーはそれらを見つけません。 –
Bo Presson、不足しているファイルを追加しました。可能であればお手伝いください。ありがとう!! – nndhawan