VC++里面,Stack怎么写?
所在版块:社会百科 发贴时间:2003-06-29 14:54

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
我写了个,好多错! 帮忙看看!

//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;

tristStack next;
int size;
};

#endif

//tristStack.cpp

#include "tristStack.h"

tristStack::tristStack() {
head = null;
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 = next.head;
next = next.next;
size--;
return temp;
}


//error message when built
--------------------Configuration: Delaunay2D - Win32 Debug--------------------
Compiling...
computeDT.cpp
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.h(19) : error C2460: 'next' : uses 'tristStack', which is being defined
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.h(7) : see declaration of 'tristStack'
tristStack.cpp
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.h(19) : error C2460: 'next' : uses 'tristStack', which is being defined
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.h(7) : see declaration of 'tristStack'
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.cpp(5) : error C2065: 'null' : undeclared identifier
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.cpp(25) : error C2440: '=' : cannot convert from 'class tristStack *const ' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.cpp(32) : error C2228: left of '.head' must have class/struct/union type
d:\urop\myproj\delaunayvisualiser\delaunay2d\triststack.cpp(33) : error C2228: left of '.next' must have class/struct/union type
Error executing cl.exe.

test2.exe - 6 error(s), 0 warning(s)

难道VC++里面,null也不能用么?
.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

Speed Up...
 相关帖子 我要回复↙ ↗回到正文
VC++里面,Stack怎么写? maserati   (2098 bytes , 604reads )
C++ 中... 风中的树叶   (849 bytes , 292reads )
谢谢 maserati   (0 bytes , 140reads )
c++和java不一样的。。 hula   (0 bytes , 165reads )