C++二叉树应用:计算表达式

2020-01-06 12:37:25刘景俊

  {

  type=t; data=d; lchild=lc; rchild=rc;

  }

  };

  node *root;

  node *create(char * &s);

  Type getToken (char * &s, int &value);

  int result (node *t);

  public:

  calc (char *s) {root=create(s);}

  int result() {if (root==NULL) return 0;

  return result(root);}

  };

  calc::node *calc::create(char * &s)

  {

  node *p, *root=NULL;

  Type returnType,flag=DATA;