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*
?: minor issue
Shouldnt the 0 implicitly cast to Data* in both cases?
I'm not one to ponder densly packed code for too long.
Why not try a structure more like the following:
One more thing, what is stored at Dataset[0], and why is it not used?
- Jacob
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
yeah, if Dataset[0] == 0, you can just
Data* pNorthwest = Dataset[get_refid("northwest")];
Data* pNorthwest = Dataset[get_refid("northwest")];
[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]
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]
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement