View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

# ?: minor issue

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Desdemona  Members

Posted 09 September 2004 - 05:37 PM

Shouldnt the 0 implicitly cast to Data* in both cases?
uint nw = get_refid("northwest");

Data* pNorthwest = nw == 0 ? 0 : Dataset[nw]; // Does not work
Data* pNorthwest = nw != 0 ? Dataset[nw] : 0; // Works

// Dataset[nw] returns Data*



### #2Kevlar-X  Members

Posted 09 September 2004 - 06:06 PM

I'm not one to ponder densly packed code for too long.
Why not try a structure more like the following:

uint nw = get_refid("northwest");Data* pNorthwest = 0;if(nw)   pNorthWest = Dataset[nw];

One more thing, what is stored at Dataset[0], and why is it not used?

- Jacob

### #3davepermen  Members

Posted 09 September 2004 - 06:21 PM

yeah, if Dataset[0] == 0, you can just

Data* pNorthwest = Dataset[get_refid("northwest")];
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

### #4Desdemona  Members

Posted 09 September 2004 - 06:50 PM

The comment was aimed more at a quirk in the langauge, not the actual code

### #5Kevlar-X  Members

Posted 09 September 2004 - 07:11 PM

Removed response, as it was related to C++ and not Angelcode.
[/edit]

WitchLord: Thanks for pointing that out. I didn't look at the forum the message was posted in, simply the topic/and post itself.
My mistake :(

Desdemona: In the future, please specify the question fully to help avoid confusion like this.
(There is a trend for people to ask questions about programming, and simply imply the language is C++. However you did the right thing and posted in the correct forum at least!)

[Edited by - Kevlar-X on September 10, 2004 12:11:21 PM]

### #6Andreas Jonsson  Moderators

Posted 10 September 2004 - 04:40 AM

davepermen and Kevlar-X:

You're missing the point [wink]. Because Desdemona's question was posted in my forum (AngelCode), I implicitly understand that the code he wrote is for AngelScript. I suppose you entered from Active Topics, in which case I can understand why you would think he's asking about normal C++ code.

Desdemona:

You're right, 0 ought to be implicitly converted to Data* in this case. AngelScript doesn't do it as it compiles 0 first and finds that it is an integer, thus it expects the second case to be integer as well. I'll see if I can fix this one, for the next versions.

Thanks for letting me know.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.