寻找有关ENUM的新闻文章作为一个类 [英] looking for Newsletter article on ENUM as a class

查看:84
本文介绍了寻找有关ENUM的新闻文章作为一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近(几周或几个月前),有一篇文章谈到了向ENUM中添加其他属性.它讨论了一个事实,在C ++中,枚举是一个类,因此可以扩展.我将这篇文章加为书签,因为它与我正在从事的项目直接相关.不幸的是我找不到书签!是否有人记得这篇文章,或者至少足以给我很好的搜索条件?

谢谢!

David

Recently (weeks or months ago)there was an article that talked about adding additional properties to ENUMs. It discussed the fact that in C++ enum was a class and so could be extended. I bookmarked the article because it directly related to a project I was working on. Unfortunately I can no longer find the bookmark! Does anyone remember the article, or at least enough of to give me good search terms?

Thanks!

David

推荐答案

您确定它是C ++吗?以防万一:11月,我发表了一篇有关类似主题的文章,但在.NET中:枚举类型不枚举!解决.NET和语言限制 [ ^ ].

我不认为枚举类型可以扩展.方法是使用泛型和反射将其包装在一个类中.我不知道如何在C ++中使用模板和RTTI进行此操作,因为RTTI没有.NET反射功能.如果您找到有关C ++主题的文章,请通知我(在此帖子中添加评论)吗?

抱歉,如果不是这样的话.

—SA
Are you sure it was C++? Just in case: in November I published an article on the similar topic, but in .NET: Enumeration Types do not Enumerate! Working around .NET and Language Limitations[^].

I don''t thing enumeration type can be extended. The approach is to wrap it in a class using generics and reflection. I don''t know how to do it in C++ with templates and RTTI, as RTTI does not have the power of .NET reflection. If you find the article on the topic for C++, will you please notify me (by adding comment to this post)?

Sorry if this is not it.

—SA


这篇关于寻找有关ENUM的新闻文章作为一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆