toozy 2013-10-06 06:17 采纳率: 0%
浏览 2650

c++模板类包含typedef 指针函数,vs2012编译错误

#include "stdafx.h"
#include<stdexcept>
#ifndef ToozyBinaryTreeHead
#define ToozyBinaryTreeHead
template <class T>
class ToozyBinaryTree{
public:
    typedef bool (*findFunc)(typename const ToozyBinaryTree<T>::ToozyBinaryTreeNode*,const T*); 
    static const int LEFT = 1;
    static const int RIGHT = 2;

    struct ToozyBinaryTreeNode{
        ToozyBinaryTreeNode *left;
        ToozyBinaryTreeNode *right;
        ToozyBinaryTreeNode *nextNode;
        T value;
        ToozyBinaryTreeNode(const T *v){
            value = *v;
            left = nullptr;
            right = nullptr;
            nextNode = nullptr;
        }
    };

    findFunc findFunction;
    ToozyBinaryTree(ToozyBinaryTreeNode *root);
    ToozyBinaryTree(T *v);
    ~ToozyBinaryTree();
    const ToozyBinaryTreeNode *find(const T *value) const;
    const ToozyBinaryTreeNode *add(const ToozyBinaryTreeNode *parent,const T *value,int type);
    const ToozyBinaryTreeNode *getRoot();
protected:
    ToozyBinaryTreeNode* _root;
    ToozyBinaryTreeNode* _lastNode;
};

这样子:
typedef bool (*findFunc)(typename const ToozyBinaryTree::ToozyBinaryTreeNode*,const T*);
应该怎么改?

  • 写回答

1条回答

  • 滴水冰冻 2014-02-17 11:15
    关注

    typedef bool (*findFunc)(typename const ToozyBinaryTree::ToozyBinaryTreeNode*,const T*);
    改为bool (*findFunc)(typename const ToozyBinaryTree::ToozyBinaryTreeNode*,const T*);
    typedef的用法不是这样用的。去查查type的用法吧。
    findFunc findFunction;这句多余了。去掉

    评论

报告相同问题?

悬赏问题

  • ¥15 求解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波