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;这句多余了。去掉

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料