好吧,我已经检查了缺少的分号,并且据我所知,我没有任何包含循环,所以我有些困惑。我一直在看其他发布的示例,但我仍然不太明白我所缺少的内容。我猜想这与我不正确处理的模板的使用有关,但是我真的不知道。

In file included from customtester.cpp:6:0:
MyBSTree.h:23:1: error: expected class-name before â{â token


文件:

#ifndef MYBSTREE_H
#define MYBSTREE_H

template <typename T>        //not sure which of these I need,
class AbstractBSTree;        //the include, the forward
#include "abstractbstree.h"  //declaration, or both.

template <typename T>
class TreeNode
{
    T m_data;
    TreeNode<T> * m_right;
    TreeNode<T> * m_left;

};

template <typename T>
class MyBSTree:public AbstractBSTree //this would be line 23
{
    TreeNode<T> * m_root;
    int m_size;
};

#endif


我有什么想念的吗?我无法修改“ abstractbstree.h”

最佳答案

尝试:

public AbstractBSTree<T>


编译器仅在模板主体内且仅对模板类使用而不在公共空间中使用<T>

10-04 15:02