Thread: Enum(s) and Memory

  1. #1
    Set Apart -- jrahhali's Avatar
    Join Date
    Nov 2002
    Posts
    256

    Question Enum(s) and Memory

    How does an enumerated data type use memory?
    let's say i have

    enum Family { brother, sister, mom, dad };

    then i define it

    Family intermediate;

    How much space is set aside for intermediate?

    And what's the difference/advantage of an enumerated data type and a whole bunch of ints?
    Clear the mines from our Shazbot!
    Get the enemy Shazbot!

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >How much space is set aside for intermediate?
    Code:
    cout<< sizeof intermediate <<endl;
    >And what's the difference/advantage of an enumerated data type and a whole bunch of ints?
    An enumeration is more restrictive and provides more protection as a result. It also acts as documentation better than a "whole bunch of ints".
    My best code is written with the delete key.

  3. #3
    Set Apart -- jrahhali's Avatar
    Join Date
    Nov 2002
    Posts
    256
    it says 4.. does this mean 4 bytes. type long?
    Clear the mines from our Shazbot!
    Get the enemy Shazbot!

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >does this mean 4 bytes.
    Yes.

    >type long?
    Does it matter?
    My best code is written with the delete key.

  5. #5
    Set Apart -- jrahhali's Avatar
    Join Date
    Nov 2002
    Posts
    256
    Jeeze!! prelude!
    thanks for answering me though
    Clear the mines from our Shazbot!
    Get the enemy Shazbot!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A snake game - Memory problem
    By gavra in forum C Programming
    Replies: 29
    Last Post: 11-23-2008, 12:58 PM
  2. VOID (my understanding is void)
    By LLINE in forum C++ Programming
    Replies: 5
    Last Post: 11-07-2008, 04:10 PM