了解しました。私はJavaとPythonから来ているので、少し我慢してください。私はインターネットでc++でヘッダーファイルを使用する方法を学ぼうと探し回っていましたが、クラスを定義するまでは大丈夫でした。これが私のコードです。
notAClock.h
#ifndef NOTACLOCK_H_
#define NOTACLOCK_H_
namespace thenewboston {
class notAClock {
public:
notAClock();
virtual ~notAClock();
int isAClock();
};
} /* namespace thenewboston */
#endif /* NOTACLOCK_H_ */
notAClock.cpp
/*
* notAClock.cpp
*
* Created on: Dec 22, 2012
* Author: pipsqueaker
*/
#include "notAClock.h"
namespace thenewboston {
notAClock::notAClock() {
// TODO Auto-generated constructor stub
}
notAClock::~notAClock() {
// TODO Auto-generated destructor stub
}
int notAClock::isAClock() {
return 0;
}
} /* namespace thenewboston */
そして最後に、私のメインファイル
#include <iostream>
#include "notAClock.h"
using namespace std;
int main() {
cout << "program works" << endl;
notAClock play;
}
Eclipseがこれをコンパイルしようとすると(私はCDTプラグインを使用しています)、エラーがスローされます。その関連部分は次のとおりです。
../src/main.cpp:13: error: 'notAClock' was not declared in this scope
../src/main.cpp:13: error: expected `;' before 'play'
make: *** [src/main.o] Error 1
私がこれから得ることができる最も多くは、notAClockがメインクラスで定義されていないということです。私は何が間違っているのですか?
-pipsqueaker117