C++枚举重新定义和 C++0x
如果我想排除 C++ 中枚举和类型重定义的问题,我可以使用以下代码:
struct VertexType
{
enum
{
Vector2 = 1,
Vertor3 = 2,
Vector4 = 3,
};
};
struct Vector2 { ... };
struct Vector3 { ... };
struct Vector3 { ... };
Is there a way to remove thewrapper above enum.我查看了 C++0x 但没有找到有关解决此问题的附加信息。
If I want to exclude problems with enums and type redefinition in C++ I can use the code:
struct VertexType
{
enum
{
Vector2 = 1,
Vertor3 = 2,
Vector4 = 3,
};
};
struct Vector2 { ... };
struct Vector3 { ... };
struct Vector3 { ... };
Is there a way to remove the wrapper above enum. I looked at C++0x but didn't find addiditional inforamtion about solving this problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您正在谈论 C++0x,因此只需使用新的
enum class
语法:枚举器值只能通过
VertexType
类型访问,如VertexType 中所示: :矢量1。
该标准的一些引用:
Since you are talking about C++0x, just use the new
enum class
syntax:The enumerator values will only be accessible through the
VertexType
type as inVertexType::Vector1
.Some quotes from the standard:
命名空间
怎么样?How about
namespace
?看来 vector3 已经被使用了。你可以做你想做的事,但是,不能使用vector3。
这对我有用,完全没有错误。
这是我找到的一个链接。
http://www.kixor.net/dev/vector3/
It appears vector3 is already being used. You can do what your trying to do, however, vector3 cannot be used.
This works for me, no errors at all.
This is a link i found.
http://www.kixor.net/dev/vector3/