Announcements | Last Post | |
---|---|---|
SoC Curricula | 09/30/2017 01:08PM | |
Demarcation or scoping of examinations and assessment | 02/13/2017 07:59AM | |
School of Computing Short Learning Programmes | 11/24/2014 08:37AM | |
Unisa contact information | 07/28/2011 01:28PM |
Re: Assignment 3 July 07, 2006 08:11AM |
IP/Host: ---.gprs.vodacom.co.za Registered: 18 years ago Posts: 1,424 Rating: 0 |
Re: Assignment 3 July 07, 2006 02:40PM |
IP/Host: ---.dbn.mweb.co.za Registered: 18 years ago Posts: 232 Rating: 0 |
Re: Assignment 3 July 11, 2006 08:45AM |
IP/Host: 196.211.24.--- Registered: 18 years ago Posts: 88 Rating: 0 |
Re: Assignment 3 July 11, 2006 03:03PM |
IP/Host: 196.31.151.--- Registered: 18 years ago Posts: 89 Rating: 0 |
Re: Assignment 3 July 11, 2006 04:04PM |
IP/Host: ---.dbn.mweb.co.za Registered: 18 years ago Posts: 232 Rating: 0 |
Re: Assignment 3 July 11, 2006 04:14PM |
IP/Host: 196.211.24.--- Registered: 18 years ago Posts: 88 Rating: 0 |
Re: Assignment 3 July 11, 2006 04:23PM |
IP/Host: ---.dbn.mweb.co.za Registered: 18 years ago Posts: 232 Rating: 0 |
Re: Assignment 3 July 11, 2006 07:15PM |
IP/Host: ---.gprs.vodacom.co.za Registered: 18 years ago Posts: 1,424 Rating: 0 |
enum Suit {Hearts, Diamonds, Clubs, Spades}; struct Card { int faceValue; Suit cardSuit; };Using enums also has the advantage in that you are restricted on what values you can assign to the variable. You can only assign the names that are defined in the list, and no other. The compiler gives each of the different elements in the list an integral value, starting at 0, and increases that value by 1 for each item in the enum list unless a value is explicitly defined by the programmer. In the above example, Hearts == 0, Diamonds == 1, Clubs == 2, and Spades == 3. Note that if you create a variable of an enum, you can only assign it the names, you cannot assign the values.
Suit cardSuit; cardSuit = 0; // invalid, not allowed to assign a numerical value cardSuit = Diamonds; // correct, using an element from the enum list
enum bool {false, true};
enum Direction {South, East, North, West};
enum Colours {Red = 0xFF0000, Green = 0x00FF00, Blue = 0x0000FF, Magenta = 0xFF00FF, Cyan = 0x00FFFF, Yellow = 0xFFFF00, // I won't carry on, you get the point };
Re: Assignment 3 July 11, 2006 08:49PM |
IP/Host: ---.saix.net Registered: 18 years ago Posts: 89 Rating: 0 |
Re: Assignment 3 July 16, 2006 12:27PM |
IP/Host: ---.wbs.co.za Registered: 18 years ago Posts: 25 Rating: 0 |
Re: Assignment 3 July 16, 2006 01:21PM |
IP/Host: ---.dbn.mweb.co.za Registered: 18 years ago Posts: 232 Rating: 0 |
Re: Assignment 3 July 16, 2006 04:14PM |
IP/Host: ---.wbs.co.za Registered: 18 years ago Posts: 25 Rating: 0 |
Re: Assignment 3 July 17, 2006 07:41AM |
IP/Host: ---.saix.net Registered: 18 years ago Posts: 1,501 Rating: 0 |
Re: Assignment 3 July 17, 2006 08:56AM |
IP/Host: ---.saix.net Registered: 18 years ago Posts: 25 Rating: 0 |
Re: Assignment 3 July 17, 2006 05:10PM |
IP/Host: ---.saix.net Registered: 18 years ago Posts: 1,501 Rating: 0 |