A basic question on enum

This is a discussion on A basic question on enum within the C++ Programming forums, part of the General Programming Boards category; Hey, I know that declaring a enum is done like this for example Code: enum wind_directions_t {NO_WIND, NORTH_WIND, SOUTH_WIND, EAST_WIND, ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    8

    A basic question on enum

    Hey,
    I know that declaring a enum is done like this for example
    Code:
    enum wind_directions_t {NO_WIND, NORTH_WIND, SOUTH_WIND, EAST_WIND, WEST_WIND};
    win_directions_t is the enum type(if i understood the tutorial well), but what if the enum doest have a type and is declared like this
    Code:
    enum {NO_WIND, NORTH_WIND, SOUTH_WIND, EAST_WIND, WEST_WIND};
    Whats the difference about having a type and not?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Well, you just won't be able to declare a variable of that type. In some cases, such as when the enumerations are being used as bitmasks, it really isn't useful to name the enum anyway, since the type can't be used directly in bit manipulation (without a cast to int).
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Jun 2009
    Posts
    8

    Thanks

    Thanks for clearing that up for me

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Visual Basic question
    By voodoo3182 in forum Windows Programming
    Replies: 11
    Last Post: 09-12-2005, 08:40 PM
  2. enum question
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 08-10-2002, 01:33 PM
  3. Visual Basic Question?
    By ob1cnobe in forum C++ Programming
    Replies: 2
    Last Post: 07-03-2002, 10:31 AM
  4. A very basic question
    By AshFooYoung in forum C Programming
    Replies: 8
    Last Post: 10-07-2001, 04:37 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21