错误:变量需要堆栈帧
// 7.7.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h "
#include <string>
#include <iostream>
using namespace std;
struct Tnode{
public:
//Tnode(string str):word(str),count(1),left(NULL),right(NULL){}
string word;
int count;
Tnode * left;
Tnode *right;
};
Tnode * new_Tnode(string const& word){
Tnode *node=new Tnode;
node-> word=word;
node-> count=1;
node-> left=node-> right=NULL;
return node;
}
void Enter_word(Tnode* &root,string const& word){
if(root!=NULL){
Tnode *node=root;
do{
int order=word.compare(node-> word);
if(0==order){
++node-> count;
break;
}else{
Tnode *&next=(order> 0)?node-> right:node-> left;
if(next==NULL){
next=new_Tnode(word);
break;
}else{
node=next;
}
}
}while(true);
}else{
root=new_Tnode(word);;
}
}
void write(std::ostream& output, Tnode* node, bool indent, int spaces=2){
if(node){
write(output, node-> left, indent,spaces+2);
if(indent)
for(int k=0; k!=spaces; ++k){
cout < < " ";
}
output < <node-> word
< < "( " < <node-> count < < ")\n ";
write(output,node-> right,indent,spaces+2);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
cout < < "enter words terminated \ "$done\ "\n ";
Tnode* tree;
while(1){
string word;
cin> > word;
if(word== "$done ")
break;
Enter_word(tree,word);
}
write(cout,tree,true,2);
getchar();
return 0;
}
哪位能帮我看一下为什么错`,并说明用的方法
附:
size_type __CLR_OR_THIS_CALL size() const
{// return length of sequence
return (_Mysize);//错误:没有找到符号_Mysize
}
[解决办法]
看看是不是什么头文件漏了...
[解决办法]
如果只是编译的话,偶用vs2005编译过了
[解决办法]
楼主的程序我这里用VC6能编译通过...