青木纯一郎 2015-10-12 07:10 采纳率: 0%
浏览 2490

vc++6.0引用list报错,list.h文件中缺少分号,为什么?

//Tree.h
#include
#include
template
class Tree{
T*NA;
list*HL;
int root;
int sizeN,sizeC;
int maxN;
public:
Tree(int n = 100):root(-1), sizeN(0), sizeC(0), maxN(n){
NA = new T[n];
HL = new list[n];
}
~Tree(){ delete[]NA; delete[]HL; }
int Empty()const{ return size == 0; }
int Full()const{ return size == maxN; }
int SizeN()const{ return sizeN; }
int SizeC()const{ return sizeC; }
int FindNode(const T&node)const;
bool FindNode(const T&node, int pos)const;
bool InsertN(const T&node);
bool InsertC(const T&parent, const T&child);
void readTree(const char*filename);
void writeTree(const char*filename);
template friend ostream&operator<<(ostream& ostr, const Tree&t);
template friend istream&operator>>(istream& istr, Tree&t);
};

template
int Tree::FindNode(const T&node)const{
for (int i = 0; i < sizeN; i++)
if (NA[i] == node)
return(i);
return -1;
}

template
bool Tree::FindNode(const T&node, int pos)const{
if (pos < 0 || pos >= sizeN)
return 0;
node = NA[pos];
return 1;
}

template
bool Tree::InsertN(const T&node){
if (sizeN == maxN)
return 0;
NA[sizeN] = node;
sizeN++;
return 1;
}
template
bool Tree::InsertC(const T&parent, const T&child){
int pi = FindNode(parent), cj = FindNode(child);
if (pi == -1 || cj == -1 || pi == cj)
return 0;
HL[pi].insert(HL[pi].end(), cj);
sizeC++;
return 1;
}
template
istream& operator>>(istream& istr,Tree& t){
char str[50];
int n;
T parent,child;
istr >> str >> n;
istr >> str >> parent;
t.InsertN(parent);
t.root = t.sizeN - 1;
istr >> str;
for (int i = 1; i <= n - 1; ++i){
istr >> child;
t.InsertN(child);
}
istr >> str >> n;
for (int j = 1; j <= n; ++j){
istr >> parent >> child;
t.InsertC(parent, child);
}
return istr;
}
template
ostream&operator<<(ostream& ostr,const Tree& t){
for (int i = 0; i < t.sizeN; i++){
ostr << i << '-' << t.NA[i] << ':';
list::iterator first = t.HL[i].begin(), last = t.HL[i].end();
for (; first != last; ++first)
ostr << '(' << *first << ')' << ' ';
ostr << endl;
}
return (ostr);
}
//main函数
#include
#include
#include
#include"Tree.h"
int main(){
TreeT(20);
int c;
cin >> c;
switch (c){
case 1:{
cout << "从磁盘提取,输出至文件" << endl;
ifstream fin;
fin.open("treein.txt", ios::in);
if (!fin){
cout << "can not open treein.txt.\n";
exit(1);
}
fin >> T;
ofstream fout;
fout.open("Etreeout.txt", ios::out);
if (!fout){
cout << "cannot open treeout.txt.\n";
exit(1);
}
fout << T;
}break;
case 2:{
cout << "从文件提取,输出至终端:" << endl;
cin >> T;
cout << "结果:\n"< }break;
}
system("pause");
return 0;
}
//输入文件信息
13
A

B C D E F G H I J K L M
12
A B
A C
A D
B E
B F
C G
D H
D I
D J
G K
G L
J M
//调试信息
d:\vc++6.0\microsoft visual studio\vc98\include\list.h(37) : error C2146: syntax error : missing ';' before identifier 'Length'
d:\vc++6.0\microsoft visual studio\vc98\include\list.h(37) : error C2501: 'DWORD' : missing storage-class or type specifiers
d:\vc++6.0\microsoft visual studio\vc98\include\list.h(37) : error C2501: 'Length' : missing storage-class or type specifiers
d:\vc++6.0\microsoft visual studio\vc98\include\list.h(53) : error C2146: syntax error : missing ';' before identifier 'GetPrevLink'
d:\vc++6.0\microsoft visual studio\vc98\include\list.h(53) : error C2433: 'WINAPI' : 'inline' not permitted on data declarations
d:\vc++6.0\microsoft visual studio\vc98\include\list.h(53) : fatal error C1004: unexpected end of file found

  • 写回答

2条回答 默认 最新

  • oyljerry 2015-10-12 07:18
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。