main()を含む1つのcppファイルがあります。別の構造体と関数(たとえば、header.hpp)に依存しています。構造体は、関数プロトタイプとともにheader.hppで定義されています。関数はheader.cppに実装されています。
コンパイルしようとすると、次のようなエラーメッセージが表示されます。
undefined reference to `see_blah(my_thing *)`
したがって、概要を説明します。
header.hpp:
#ifndef HEADERDUR_HPP
#define HEADERDUR_HPP
struct my_thing{
int blah;
};
int see_blah(my_thing*);
#endif
header.cpp:
#include "header.hpp"
int see_blah(my_thing * thingy){
// ...
}
main.cpp:
#include <iostream>
#include "header.hpp"
using namespace std;
int main(void)
{
thinger.blah = 123;
cout << see_blah(&thinger) << endl;
return 0;
}
何が間違っているのかわからず、答えも見つかりません。回答ありがとうございます、彼らは非常に感謝しています!