Teen Programmers Unite  


Return to forum top

User Defined Types

Posted by Brok3n_Link [send private reply] at July 13, 2002, 10:49:02 PM

Hi all,
I need some help with user defined types or the like.
I need a Type, or something similar that allows me to have mutiple types?


Type PlayerCharacter
Owner as string
Name as string
' somemore stuff here
LeftHand as HandType
RightHand as HandType
End Type

type handtype

end type

Posted by Zandalf [send private reply] at July 13, 2002, 11:40:29 PM

sounds like classes to me, but then again I'm just a C++ progger, so I'm unfamiliar with most other languages. what language are you trying to program in here, and maybe I'll (or someone else) will be able to help...

Posted by CodeRed [send private reply] at July 14, 2002, 01:25:43 AM

I'll assume you are using C++, you can do this two ways, with structs or with classes, it really doesn't matter which.

class Hand

class Player
    string owner;
    string name;
    Hand leftHand;
    Hand rightHand;

I guess....
Posted by taubz [send private reply] at July 14, 2002, 07:13:31 PM

There's no reason why you can't do what you're doing (in VisualBasic I presume). Just make sure that if type A is within type B, A must appear in your code before B.

- taubz

Posted by AngelOD [send private reply] at July 15, 2002, 06:35:01 AM

Yup, taubz is right. Move the 'HandType' declaration above the 'PlayerCharacter' declaration, and it should work perfectly. :o)

Posted by Brok3n_Link [send private reply] at July 15, 2002, 06:45:28 AM

ah! has to be before eh?
ok that fixes the problem, thanx a lot.

Brok3n Link

You must be logged in to post messages and see which you have already read.

Log on
Save for later automatic logon

Register as a new user
Copyright TPU 2002. See the Credits and About TPU for more information.