非法使用此类型作为表达式- VS 2012

Illegal use of this type as an expression - VS 2012

本文关键字:表达式 VS 2012 类型 非法      更新时间:2023-10-16

当编译我的源代码时,我得到了这个错误,'MPageArrayCursor':非法使用这种类型作为表达式在源代码的这一部分:

class MPageArrayCursor { 
protected: 
    int m_nIndex;
public: 
    MPageArrayCursor(int nIndex) { 
        m_nIndex = nIndex; 
    } 
    virtual ~MPageArrayCursor(); 
    int GetIndex() {
        return m_nIndex; 
    } 
    void SetIndex(int nIndex) {
        m_nIndex = nIndex;
    } 
};
void Add(T pData, MPageArrayCursor* pCursor=NULL)
{
    int nFreeSlot = m_UnusedQueue.top();
    m_UnusedQueue.pop();
    Set(nFreeSlot, pData, pCursor);
}

最初是一个vc++ 2k10解决方案,我移植到2k12。为什么会出现这个错误?

这是完整的代码:http://pastebin.com/xjVKCZjZ

你的代码工作得很好,除了你需要在VS2012上包含std::greater function operator的函数头

#include <functional>