繁体   English   中英

Visual Studio 2012 Professional无法识别类 - 有时候

[英]Visual Studio 2012 Professional doesn't recognize a class - sometimes

据我所知,我的代码没有实际问题,但是Visual Studio无法识别我的* .h文件中的特定类。 它识别前面的结构和刚刚之后的类 - 如果我放入一个额外的

class test {
    int foo;
public:
    void bar();
}

就在之前,它找到它(但现在它没有找到test 。)

澄清一下:通过识别,我说的是两件事:代码窗口顶部的范围栏,以及扩展FooBar.h的列表。 前者坚持认为类中的空间仍然是“全局范围”,后者列出了我的所有函数,就好像它们是全局的一样。

这仍然存在于reparses中 - 如上所述,我可以通过添加类test来解决问题,并通过删除虚拟类来重新创建它。

IntelliSense仍然将类及其方法识别为属于该类,这显然是奇怪的......

实际代码如下。

//This shows up fine: expanding FooBar.h reveals a sub-list called Update, with
//fields "pE, pEgivenH, E" and methods "Update(...), ~Update(), operator=," and so on.
struct Update {
public:
    double pEgivenH, pE;
    EvidenceID E;

    Update(double, double, EvidenceID);
    ~Update();
    Update &operator=(const Update &rhs);
    int operator==(const Update &rhs) const;
    int operator<(const Update &rhs) const;
}

// Point A

// This doesn't, though. When the cursor is placed within this class, the bar insists
// that it is "global scope", and all methods here show up as global methods under 
// FooBar.h. The problem goes away if I add a class at Point A.
class Hypothesis {
    string hypothesis;
    double currentP;
    double prior;
public: 
    list<Update> history;

    ~Hypothesis();
    Hypothesis &operator=(const Hypothesis &rhs);
    int operator==(const Hypothesis &rhs) const;
    int operator<(const Hypothesis &rhs) const;

    Hypothesis(string, double);
    double updateHypothesis(Update);
    double recalcHypothesis();
    string getHypothesis();
    double getProbability();
}

// This class also shows up fine.
class Action {
    ActionType type;
    Update ubefore, uafter;
    Hypothesis hbefore, hafter;
    EvidenceID ebefore;
public:
    void undo();
    void redo();      
}

看起来你只是在每个结构/类后丢失分号。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM