gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 20:04:39 29 4
gpt4 key购买 nike

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

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

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

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

这在重新分析中仍然存在 - 如上所述,我可以通过添加类 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();
}

最佳答案

看起来您只是在每个结构/类之后缺少分号。

关于c++ - Visual Studio 2012 Professional 无法识别类 - 有时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18222469/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com