1

私はこのプログラムの最初のステップにいるだけですが、コードを作成しているのでコンパイルするのが好きです。また、私はADTを初めて使用するので、このコードを作成するときに、それらが何を意味するのかわからないいくつかの問題に遭遇しました。

式.h

#include "header.h" //Library that contains thing like iomanip, cstring, etc.

class Expression
{
        private:
          char *ieEXP; //Array of characters
          char *peEXP; //Array of characters
          const int MAX = 40; //Max size for the array
        public:
          //Initialize both arrays to 0
          Expression(){ieEXP[MAX] = {0}, peEXP[MAX] = {0}};

          Expression(const Expression &);

          //Destroy contents within the array after program completes
          ~Expression(){ieEXP[MAX] = {0}, peEXP[MAX] = {0}};


          //void ReadInFix(char *ieEXP);
          //void PrintInFix(char *ieEXP);
          //void StrCatch();
          //bool IsOperator();
          //void IntoPostFix(char *peEXP);
          //void PrintPostFix(char *peEXP);
          //int Priority();
};

コンパイル

g++ -c Expression.h

これは私が得る正確なエラーです

Expression.h:1: error: expected constructor, destructor, 
or type conversion before string constant

また、他のメソッドはまだ使用されておらず、単にクラスを作成しただけであり、int main はまだ何も呼び出されていません。

ありがとうございました。

4

2 に答える 2

1

g++ は *.h をソース ファイルとして認識しないため、解決策はおそらくヘッダー ファイルをコンパイルしないことです。おそらく、ヘッダーを含む .cpp ファイルを作成し、それをコンパイルする必要あります。g++ は .cpp を認識し、適切に処理します。

于 2012-10-15T21:05:18.190 に答える
0
Expression(){ieEXP[MAX] = {0}, peEXP[MAX] = {0}};

ieEXP と peEXP は配列ではなくポインタです。

于 2012-10-15T21:00:26.403 に答える