Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 21st, 2005, 11:44 AM   #1
SittingDuck
Programmer
 
SittingDuck's Avatar
 
Join Date: Nov 2005
Location: Moseley, Birmingham, England, Earth
Posts: 51
Rep Power: 3 SittingDuck is on a distinguished road
Unions

How are unions declared in Delphi? I know they're something like this:

type
	TRecord = record
		case Integer of
			0: (A: Integer);
			1: (B: Single);
	end;

But I don't understand exactly what's going on.
SittingDuck is offline   Reply With Quote
Old Nov 21st, 2005, 8:32 PM   #2
Scorpions4ever
Programmer
 
Join Date: Jun 2005
Posts: 86
Rep Power: 4 Scorpions4ever is on a distinguished road
Pascal is actually a very type-strict language and this is actually one of the documented ways that Wirth himself specified to break type checking. It is part of the PASCAL language specification.

Another way is:
type
	TRecord = record
		case Boolean of
			False: (A: Integer);
			True: (B: Single);
	end;
Scorpions4ever is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:10 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC