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

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
    关注
    评论

报告相同问题?

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境