Conditional operator issue?

Static_cast(c. GetD1()) : static_cast(c. GetD2())).

Yep, this works perfectly. – laura Nov 27 '09 at 9:08 1 You only need one of the casts here too, which makes the expression a little less verbose. – Richard Corden Nov 27 '09 at 19:20 @Richard, ah good note.To me it looks easier if I apply the cast to both operands, but you are of course right, one cast suffices to make the compiler see the other one can be converted to D& implicitly.

– Johannes Schaub - litb Nov 27 '09 at 20:42.

Btw, you don't really need to use a conditional operator, D* dptr; if(rand() %2 == 0) dptr = &c. GetD1(); else dptr = &c. GetD2(); D& d = *dptr; would work too.

This looks to be a little wasteful. Is there a benifit to this approach verses the Ternary operator? – Stephen Edmonds Nov 27 '09 at 9:52 This is true, but I find the code looks clunky if you do this (using the reference looks cleaner).

– laura Nov 27 '09 at 9:53 1 Stephen, I was only providing an answer in response to OP's "but I don't know how to get my reference to D without using the ternary operator" – Murali VP Nov 27 '09 at 9:54 2 I suspect this falls into the category "personal preference": I do find it less clunky, especially since in this case a normal (D&)-cast is enough (casting to base class) so the ternary operator is perfectly readable and you don't have an extra variable which will be unused later on. I'm not sure the cast qualifies as RTTI use. Your answer, however, is perfectly valid, I do not understand why it was down-voted.

– laura Nov 27 '09 at 10:27.

Or you can change the return types of the functions to Base Class.

This would pepper the rest of the code using the two getters with dynamic casts, it's not really a solution – laura Nov 27 '09 at 9:54 you are right, static_cast should work. – shyam Nov 27 '09 at 12:15.

Here we introduce conditional comments, which offer advantages over scripted browser detection techniques. Conditional comments make it easy to detect earlier versions of Windows Internet Explorer. Conditional comments are the preferred means of differentiating Cascading Style Sheets (CSS) rules intended for specific versions of Internet Explorer.

Important  As of Internet Explorer 10, conditional comments are no longer supported by standards mode. Use feature detection to provide effective fallback strategies for website features that aren't supported by the browser. For more info about standards mode, see Defining Document Compatibility.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions