?: minor issue

Started by
4 comments, last by WitchLord 19 years, 7 months ago
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*

Advertisement
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
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
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

The comment was aimed more at a quirk in the langauge, not the actual code
[edit]
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]
"1 is equal to 2 for significantly large quantities of 1" - Anonymous
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

This topic is closed to new replies.

Advertisement