Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Strongly typed enum question

29 views
Skip to first unread message

Joseph Hesse

unread,
Apr 30, 2015, 1:03:42 PM4/30/15
to
Hello,

In C++ 11, why can't I write:

enum class Values = {1, 2, 3};

Thank you,
Joe

Joseph Hesse

unread,
Apr 30, 2015, 1:05:17 PM4/30/15
to
Hello,

In C++ 11, why can't I write:

enum class Values = {1, 2, 3};

I want to treat 1 as a symbol with no meaning.

Thank you,
Joe

Öö Tiib

unread,
Apr 30, 2015, 1:14:33 PM4/30/15
to
On Thursday, 30 April 2015 20:05:17 UTC+3, Joseph Hesse wrote:
> Hello,
>
> In C++ 11, why can't I write:
>
> enum class Values = {1, 2, 3};
>
> I want to treat 1 as a symbol with no meaning.

Unfortunately to you C++ language has already given a meaning
to 1. It is integer constant that is often named "one" in English.
You are not allowed to modify that meaning by C++ language rules.

Richard

unread,
Apr 30, 2015, 1:24:02 PM4/30/15
to
[Please do not mail me a copy of your followup]

Joseph Hesse <jo...@gmail.com> spake the secret code
<houdnZ_h-sFe_d_I...@giganews.com> thusly:

>I want to treat 1 as a symbol with no meaning.

1 is not a symbol; it is an integer literal.

A symbol is an identifier and must follow the rules for identifiers in C++.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
The Terminals Wiki <http://terminals.classiccmp.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Message has been deleted
0 new messages