C++ 中...
1. null 必须大写,也就是 NULL;
2. 类tristStack还没定义,所以不能用;可用指针.
下面是改过的程序:
//tristStack.h
#ifndef _TRISTSTACK_H_INCLUDE
#define _TRISTSTACK_H_INCLUDE
#include "Trist.h"
class tristStack {
public:
tristStack();
~tristStack();
void pushTrist (Trist t);
Trist popTrist ();
bool isEmpty();
int getSize();
Trist head;
void * next;
int size;
};
#endif
//tristStack.cpp
#include "tristStack.h"
tristStack::tristStack() {
head = Trist();
next = NULL;
size=0;
}
tristStack::~tristStack() {
}
bool tristStack::isEmpty () {
if (size == 0)
return true;
return false;
}
int tristStack::getSize() {
return size;
}
void tristStack::pushTrist(Trist t){
next = this;
head = t;
size++;
}
Trist tristStack::popTrist() {
Trist temp = head;
head = ((tristStack *)next)->head;
next = ((tristStack *)next)->next;
size--;
return temp;
}
2. 类tristStack还没定义,所以不能用;可用指针.
下面是改过的程序:
//tristStack.h
#ifndef _TRISTSTACK_H_INCLUDE
#define _TRISTSTACK_H_INCLUDE
#include "Trist.h"
class tristStack {
public:
tristStack();
~tristStack();
void pushTrist (Trist t);
Trist popTrist ();
bool isEmpty();
int getSize();
Trist head;
void * next;
int size;
};
#endif
//tristStack.cpp
#include "tristStack.h"
tristStack::tristStack() {
head = Trist();
next = NULL;
size=0;
}
tristStack::~tristStack() {
}
bool tristStack::isEmpty () {
if (size == 0)
return true;
return false;
}
int tristStack::getSize() {
return size;
}
void tristStack::pushTrist(Trist t){
next = this;
head = t;
size++;
}
Trist tristStack::popTrist() {
Trist temp = head;
head = ((tristStack *)next)->head;
next = ((tristStack *)next)->next;
size--;
return temp;
}