不命名A在C ++中键入 [英] Does Not Name A Type in C++
问题描述
在C ++当我得到一个错误,说xxxxx不命名一个类型在yyy.h
这是什么意思?
yyy.h
包含 xxxx
的标头。
例如,我使用:
typedef CP_M_ReferenceCounted FxRC;
,我已将 CP_M_ReferenceCounted.h
yyy.h
我缺少一些基本的理解,是什么?
这似乎需要相应地引用命名空间。例如,下面的yyy.h和test.cpp与你的问题相同:
// yyy.h
#ifndef YYY_H__
#define YYY_H__
命名空间Yyy {
class CP_M_ReferenceCounted
{
}
}
#endif
//test.cpp
#includeyyy.h
$ b b typedef CP_M_ReferenceCounted FxRC;
int main(int argc,char ** argv)
{
return 0;
}
错误是
...错误:CP_M_ReferenceCounted未命名类型
但添加一行using namespace Yyy;解决了以下问题:
// test.cpp
#includeyyy.h
// add this line
using namespace Yyy;
typedef CP_M_ReferenceCounted FxRC;
...
因此,请检查.h头文件中的命名空间范围。 p>
in C++ when i get an error that says xxxxx does not name a type in yyy.h
What does that mean?
yyy.h
has included the header that xxxx
is in.
Example, I use:
typedef CP_M_ReferenceCounted FxRC;
and I have included CP_M_ReferenceCounted.h
in yyy.h
I am missing some basic understanding, what is it?
That seems you need to referring the namespace accordingly. For example, following yyy.h and test.cpp have the same problem as yours:
//yyy.h
#ifndef YYY_H__
#define YYY_H__
namespace Yyy {
class CP_M_ReferenceCounted
{
};
}
#endif
//test.cpp
#include "yyy.h"
typedef CP_M_ReferenceCounted FxRC;
int main(int argc, char **argv)
{
return 0;
}
The error would be
...error: CP_M_ReferenceCounted does not name a type
But add a line "using namespace Yyy;" fixs the problem as below:
//test.cpp
#include "yyy.h"
// add this line
using namespace Yyy;
typedef CP_M_ReferenceCounted FxRC;
...
So please check the namespace scope in your .h headers.
这篇关于不命名A在C ++中键入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!