小编Van*_*ana的帖子

“T”不是参数“T”的有效模板类型参数

我编写了一个程序,使用 C++ 类将排序数组转换为 BST。我收到以下错误:

error C2143: syntax error : missing ';' before '*'

error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

error C2065: 'T' : undeclared identifier

error C2923: 'Binary_Search_Tree' : 'T' is not a valid template type argument for parameter 'T'
Run Code Online (Sandbox Code Playgroud)

以下是我的程序:

template <class T>
class Binary_Search_Tree {
public:
    struct Bst_Node {
        T value;
        Bst_Node* left;
        Bst_Node* right;
    };

    Bst_Node* root;

    Binary_Search_Tree();

    Bst_Node* sortedarraytobst(T* A, int start, int end);
};

template <class T> …
Run Code Online (Sandbox Code Playgroud)

c++ templates class

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

c++ ×1

class ×1

templates ×1