问题描述
我是C ++的新手。我过去主要使用Delphi。在Delphi中,有
套。例如:
TMyType =(nOne,nTwo,nThree);
var MyNumber:TMyType;
如果[nOne,nTwo]中的MyNumber那么等等......
C ++中的等价物是什么?
谢谢。
I am new to C++. I used mostly Delphi in the past. In Delp there was
sets. For example:
TMyType = (nOne, nTwo, nThree);
var MyNumber: TMyType;
if MyNumber in [nOne, nTwo] then blah blah...
What is the equivalent in C++ ?
Thanks.
推荐答案
不确定,但我想你正在寻找类似的东西:
enum TMyType {nOne,nTwo,nThree};
TMyType MyNumber;
if(MyNumber = = nOne || MyNumber == nTwo){blah blah}
Not sure, but I guess you''re searching something like:
enum TMyType { nOne, nTwo, nThree };
TMyType MyNumber;
if (MyNumber == nOne || MyNumber == nTwo) { blah blah }
本机不支持集合(或者在STL afaik中)所以你会发现你需要找到第三方库或自己动手,就像在C ++中有这么多的东西一样。我有点忙,但是如果你没有更好的答案
当我稍后再回来看时,我会为你做一点''班级套餐'
提供固定支持。
-
Ben Radford
"为什么吸毒成瘾者和电脑aficionados都被称为用户?"
There is no support for sets natively (or in the STL afaik) so you''ll
have to find a 3rd party library or roll your own, as with so many
things in C++. I''m a bit busy atm but if you don''t have a better answer
when I check back later I''ll made a little ''class Set'' for you that
provides set support.
--
Ben Radford
"Why is it drug addicts and computer aficionados are both called users?"
这篇关于设置运营商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!