请教一个编译错误问题,谢谢帮忙。

HT1024 2009-05-08 01:26:36
#include "iostream.h"

template<class T>class BTree;

template<class T>
class BTNode{
friend class BTree<T>;
private:
T data;
BTNode<T> *rchild,*lchild;
};

template<class T>
class BTree{
public:
BTree(){root=NULL;}
protected:
BTNode<T>* root;
};

template<class T>
class HFMTree:public BTree<T>{
private:
T w;
};

template<class T>
class MinPQueue{
public:
MinPQueue(int maxSize){q=new T[maxSize];mSize=maxSize;size=0;}
private:
int size,mSize;
T* q;
};

int main(){
MinPQueue<HFMTree<int>> pq(20);

//.....

return 0;
}



--------------------Configuration: hfm3 - Win32 Debug--------------------
Compiling...
main.cpp
f:\c++\hfm3\main.cpp(37) : error C2146: syntax error : missing ',' before identifier 'pq'
f:\c++\hfm3\main.cpp(37) : error C2065: 'pq' : undeclared identifier
f:\c++\hfm3\main.cpp(37) : error C2143: syntax error : missing '>' before ';'
执行 cl.exe 时出错.

hfm3.exe - 1 error(s), 0 warning(s)


谁能帮忙解释下这是怎么回事?谢谢。
...全文
88 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Flyinsky1 2009-05-08
  • 打赏
  • 举报
回复
晕,没刷新.都结贴了
Flyinsky1 2009-05-08
  • 打赏
  • 举报
回复
>> 给它分为:> >
即:
MinPQueue <HFMTree <int> > pq(20);
HT1024 2009-05-08
  • 打赏
  • 举报
回复
我用的VC6.0.
汗,加个空格就好了!!
谢谢大家,都很厉害啊。
jame2001 2009-05-08
  • 打赏
  • 举报
回复
Crtl+Alt+F7
重建方案
wrinky 2009-05-08
  • 打赏
  • 举报
回复
我的代码就把#include "iostream.h"改成了<iostream>,这是编译器版本不同所以才改的。
goodname 2009-05-08
  • 打赏
  • 举报
回复
MinPQueue <HFMTree <int> > pq(20); //加上空格,老的编译器需要这样。
coverallwangp 2009-05-08
  • 打赏
  • 举报
回复

#include "iostream.h"

template <class T>class BTree;

template <class T>
class BTNode{
friend class BTree <T>;
private:
T data;
BTNode <T> *rchild,*lchild;
};

template <class T>
class BTree{
public:
BTree(){root=NULL;}
protected:
BTNode <T>* root;
};

template <class T>
class HFMTree:public BTree <T>{
private:
T w;
};

template <class T>
class MinPQueue{
public:
MinPQueue(int maxSize){q=new T[maxSize];mSize=maxSize;size=0;}
private:
int size,mSize;
T* q;
};

int main(){
MinPQueue <HFMTree <int> > pq(20); //加个空格就好了

//.....

return 0;
}
wrinky 2009-05-08
  • 打赏
  • 举报
回复
我刚在VS2008编译了一下,没有问题啊。楼主再试一下。

64,661

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧