Followers 0

?: minor issue

5 posts in this topic

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*


0

Share on other sites
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
0

Share on other sites
yeah, if Dataset[0] == 0, you can just

Data* pNorthwest = Dataset[get_refid("northwest")];
0

Share on other sites
The comment was aimed more at a quirk in the langauge, not the actual code
0

Share on other sites

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]
0

Share on other sites
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.
0

Create an account

Register a new account

Followers 0

• 19
• 14
• 23
• 11
• 28