template <class T>
struct stkNode
{
BinTreeNode<T> *ptr;
enum tag {R,L}tag;
stkNode(BinTreeNode<T> *N = NULL) : ptr(N),tag(L){}
};
template<class T>
void BinaryTree<T>::PostOrder(void(*visit)(BinTreeNode<T> *p))
{
SeqStack<stkNode<T> > S;
stkNode<T> w;
BinTreeNode<T> *p = root;
do
{
while (p != NULL)
{
w.ptr = p;
w.tag = w.L;
S.Push(w);
p = p->leftChild;
}
bool continuel = true;
while (!S.IsEmpty() && continuel)
{
S.Pop(w);
p = w.ptr;
switch (w.tag)
{
case w.L: //---------------this line--------------------------
w.tag = w.R;
S.Push(w);
continuel = false;
p = p->rightChild;
break;
case w.R: // -----------and this line-------------
visit(p);
break;
}
}
} while (!S.IsEmpty());
}
DevC++でコンパイルすると、エラーになります: [エラー] '。'定数式には現れません。 しかし、Visual Studio 2015でコンパイルするとエラーは発生しません。 なぜ??????'。'定数式には現れません
-----------だった な
#include <iostream>
using namespace std;
struct exp
{
char ch;
enum dir{
L,R
}direction;
exp(char name,dir d){
ch = name;
direction = d;
}
};
int main()
{
exp t('a',exp.L); //this line
return 0;
}
として--------------------私の問題を更新同じ
このコードは不完全であり、すべてでコンパイルされません。 [mcve]を作成してください。 – Johan
さて、私はそれを更新しました。 –
2番目の例は異なり、範囲演算子 'exp :: L'を使って修正することができます。最初のケースでは、ドットの左側に変数があり、2番目のケースではタイプです。 –