Можно ли на сях сделать перечисление констант?

Тема в разделе "WASM.BEGINNERS", создана пользователем KaPax, 17 дек 2008.

  1. KaPax

    KaPax New Member

    Публикаций:
    0
    Регистрация:
    15 дек 2008
    Сообщения:
    10
    Как в сях перечислить константы?

    Например нужно сделать так:
    A = 1
    B = 2
    C = 3
    ...


    Если какие-то варианты, кроме дефайна?
     
  2. Partner

    Partner Павел

    Публикаций:
    0
    Регистрация:
    28 фев 2008
    Сообщения:
    917
    Адрес:
    Los Angeles
    enum MyEnum
    {
    A = 1,
    B = 2,
    C = 3
    };
     
  3. gazlan

    gazlan Member

    Публикаций:
    0
    Регистрация:
    22 май 2005
    Сообщения:
    414
    enum LETTERS { A = 1, B, C };

    enum [tag] {enum-list} [declarator]; // for definition of enumerated type

    enum tag declarator; // for declaration of variable of type tag

    The enum keyword specifies an enumerated type.

    An enumerated type is a user-defined type consisting of a set of named constants called enumerators. By default, the first enumerator has a value of 0, and each successive enumerator is one larger than the value of the previous one, unless you explicitly specify a value for a particular enumerator. Enumerators needn’t have unique values. The name of each enumerator is treated as a constant and must be unique within the scope where the enum is defined. An enumerator can be promoted to an integer value. However, converting an integer to an enumerator requires an explicit cast, and the results are not defined.

    In C, you can use the enum keyword and the tag to declare variables of the enumerated type. In C++, you can use the tag alone.
     
  4. qteam

    qteam New Member

    Публикаций:
    0
    Регистрация:
    25 мар 2009
    Сообщения:
    27