Custom variable types in C++

This is a discussion on Custom variable types in C++ within the C++ Programming forums, part of the General Programming Boards category; Is there an (easy) way to declare a custom variable in C++? I'm new to the language, but I know ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    3

    Custom variable types in C++

    Is there an (easy) way to declare a custom variable in C++? I'm new to the language, but I know how to program in Delphi.

    In Delphi, an example would be:

    Code:
    type
      TCard = (A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K);
    To those unfamiliar with delphi, what the above code does is create a new variable type (called TCard) that can keep any of the values in the brackets, but no others (so in this case it can hold any of the integers 2-10 and the chars A, J, Q and K).

    Note that i'm not looking for information on how to declare structures or classes, I want a single variable to hold a certain kind of data.

    I tried looking for more information on the subject on this forum, the MSVC.NET helpfile and using google, but as I'm not even sure what this is called that didn't give me too much information.

    -Aeroren

  2. #2
    C(++)(#)
    Join Date
    Jul 2004
    Posts
    309
    Would enumerations be what you are looking for?
    To code is divine

  3. #3
    Registered User
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    3
    Why, yes Thank you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 05:23 AM
  2. Need some help...
    By darkconvoy in forum C Programming
    Replies: 32
    Last Post: 04-29-2008, 04:33 PM
  3. float/double variable storage and precision
    By cjschw in forum C++ Programming
    Replies: 4
    Last Post: 07-28-2003, 07:23 PM
  4. Beginner question
    By Tride in forum C Programming
    Replies: 30
    Last Post: 05-24-2003, 09:36 AM
  5. variable types
    By chavezbri in forum C Programming
    Replies: 3
    Last Post: 01-16-2003, 02:39 PM

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