私はC++を使い慣れていますので、これは愚かな質問です。私は、そのパラメータで3つの配列を持つ関数を作成しようとしています。私は、それぞれが宣言されていないというエラーが出ています。ヘッダ内関数内のC++配列のパラメータが宣言されていません
コード: #ifndefのADDRESSMODEL の#define ADDRESSMODELの#define ADDRESSDEBUG主に
#include <iostream>
#include <string.h>
using namespace std;
class PostCode
{
public:
PostCode(void);
~PostCode();
void postCodeCompare(tempPostCode[], theRoutingArray[], theIdentifier[]);
private:
char theRoutingArray[4];
char theIdentifier[5];
char tempPostCode[8];
};
inline PostCode :: PostCode(void)
{
strcpy(theRoutingArray, "000");
strcpy(theIdentifier, "0000");
cout << "Debug constructor called" << endl;
}
inline PostCode :: ~PostCode()
{
cout<< "Destructor" << endl;
}
inline int PostCode :: postCodeCompare(tempPostCode, theRoutingArray, theIdentifier)
{
char postCode[] = theRoutingArray + theIdentifier;
if (postCode[0] == tempPostCode[0]){
cout << 1 << endl;
}
else{
cout << 0 << endl;
}
}
#endif
コード: の#include "がheader.h" 名前空間stdを使用。
int main(void){
cout << "main has started" << endl;
PostCode myCode;
char theRoutingArray[4];
char theIdentifier[5];
char tempPostCode[8];
cout << "Please type in your routing key: " << endl;
cin.getline(theRoutingArray, 4);
cout << "Please type in your identifier: " << endl;
cin.getline(theIdentifier, 5);
PostCode.postCodeCompare();
cout << "main has finished" << endl;
return 0;
}
アドバイスをいただければ幸いです。
あなたが適切に彼らはちょうどあなたのプライベートなメンバーであることを意味しているように見えるあなたのpostCodeCompareメソッドへの入力を、宣言していません。また、そのメソッドにポインターを追加してもよろしいですか?より明確な機能とより簡単なコードを得るために 'std :: string'に切り替えることをお勧めします。 – Nonanon