Thread: A basic question on enum

  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, 07:40 PM
  2. enum question
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 08-10-2002, 12:33 PM
  3. Visual Basic Question?
    By ob1cnobe in forum C++ Programming
    Replies: 2
    Last Post: 07-03-2002, 09:31 AM
  4. A very basic question
    By AshFooYoung in forum C Programming
    Replies: 8
    Last Post: 10-07-2001, 03:37 PM