Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK .NET / question about inheritance

Author
Message
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Jan 2010 15:49
I have created a new class which inherits Basic3D.object3D. I can use Pick on these objects and successfully detect them. The next part of my problem now is to establish whether my object is created from my new class and interrogate it's new properties.

1. Use Pick and get a n object number - Works OK
2. Establish whether it is made from my new Class - How?
3. Interrogate new property ObjectType - How?




Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Jan 2010 15:10


BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Jan 2010 12:27
thanks!

kBessa
17
Years of Service
User Offline
Joined: 8th Nov 2006
Location: Manaus, Amazonas, Brazil
Posted: 8th Jan 2010 15:07
Here is a better (and more elegant) example. Use it when you need to check for objets types without any casting:

PS: C# Code



A little bit explanation of the four checks:

The first one returns false, because it is of Parent type, not Child.

The second returns true, because it is a Child object.

The third returns true, as a Parent variable may receive a Child object, as it is a inherited class (OO fundamentals).

The fourth returns false, because as the Child objectwas inherited from Parent, it is expected that it will have more methods, variables, etc. So a variable of its type will not accept receiving an object of its parent type.

[center][center]
Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 9th Jan 2010 11:41
@kBessa
In VB, my method is probably better, since the documentation says that VB's casting functions are specially optimised for the language, and it advises to use them instead of the ones in the .net framework, which have to work with all languages.

Login to post a reply

Server time is: 2024-04-24 23:48:06
Your offset time is: 2024-04-24 23:48:06