How is the return type of ternary operator determined?Why ternary operator does not support blocks?How do you set, clear, and toggle a single bit?How do I iterate over the words of a string?Does Python have a ternary conditional operator?What is the “-->” operator in C++?What are the basic rules and idioms for operator overloading?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Can't use modulus on doubles?error: 'invalid operands' to binary operator <<Kotlin Ternary Conditional OperatorC++ Trouble compiling cout with a += statement

Are children a reason to be rejected for a job?

Is Odin inconsistent about the powers of Mjolnir?

How is the return type of ternary operator determined?

Why do proponents of guns oppose gun competency tests?

How to check a file was encrypted (really & correctly)

Print only the last three columns from file

Does the Voyager team use a wrapper (Fortran(77?) to Python) to transmit current commands?

Is there a drawback to Flail Snail's Shell defense?

Unexpected route on a flight from USA to Europe

Who is the god Ao?

Is DC heating faster than AC heating?

Best way to explain to my boss that I cannot attend a team summit because it is on Rosh Hashana or any other Jewish Holiday

How would a family travel from Indiana to Texas in 1911?

What could prevent players from leaving an island?

How can glass marbles naturally occur in a desert?

Do any languages mention the top limit of a range first?

Why do private jets such as Gulfstream fly higher than other civilian jets?

Did Apollo leave poop on the moon?

Did WWII Japanese soldiers engage in cannibalism of their enemies?

Why is there a need to prevent a racist, or homophobic, etc. vendor from discriminating who they sell to?

How to continue a line in Latex in math mode?

Is it a bad idea to offer variants of a final exam based on the type of allowed calculators?

Does the United States guarantee any unique freedoms?

Why should public servants be apolitical?



How is the return type of ternary operator determined?


Why ternary operator does not support blocks?How do you set, clear, and toggle a single bit?How do I iterate over the words of a string?Does Python have a ternary conditional operator?What is the “-->” operator in C++?What are the basic rules and idioms for operator overloading?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Can't use modulus on doubles?error: 'invalid operands' to binary operator <<Kotlin Ternary Conditional OperatorC++ Trouble compiling cout with a += statement






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








6















I was solving a problem about bishop on a chessboard. At one point of my code, I included the following line:



std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


This generates the following error:



error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'


However, I instantaneously fixed this error by including an additional variable in my code:



int steps = (abs(c2-c1) == abs(r2-r1)) ? 1 : 2;
std::cout << steps << std::endl;


Now I have this question in my mind how the ternary operator works and how it's return type is determined (as the compiler called it <unresolved overloaded function type>).










share|improve this question



















  • 2





    I think the ternary operator has precedence over the << operator. And so the first branch of the ternary was 1, and the other 2 << std;:endl

    – Neo
    11 hours ago











  • Look at operator precedence. << is higher than == and ?? (see: en.cppreference.com/w/cpp/language/operator_precedence)

    – ChuckCottrill
    11 hours ago






  • 3





    This also fixes the error: std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;. No need for an intermediate variable.

    – PaulMcKenzie
    11 hours ago












  • Here is an interesting question I found searching through this site before asking here.

    – Meraj al Maksud
    11 hours ago

















6















I was solving a problem about bishop on a chessboard. At one point of my code, I included the following line:



std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


This generates the following error:



error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'


However, I instantaneously fixed this error by including an additional variable in my code:



int steps = (abs(c2-c1) == abs(r2-r1)) ? 1 : 2;
std::cout << steps << std::endl;


Now I have this question in my mind how the ternary operator works and how it's return type is determined (as the compiler called it <unresolved overloaded function type>).










share|improve this question



















  • 2





    I think the ternary operator has precedence over the << operator. And so the first branch of the ternary was 1, and the other 2 << std;:endl

    – Neo
    11 hours ago











  • Look at operator precedence. << is higher than == and ?? (see: en.cppreference.com/w/cpp/language/operator_precedence)

    – ChuckCottrill
    11 hours ago






  • 3





    This also fixes the error: std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;. No need for an intermediate variable.

    – PaulMcKenzie
    11 hours ago












  • Here is an interesting question I found searching through this site before asking here.

    – Meraj al Maksud
    11 hours ago













6












6








6


3






I was solving a problem about bishop on a chessboard. At one point of my code, I included the following line:



std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


This generates the following error:



error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'


However, I instantaneously fixed this error by including an additional variable in my code:



int steps = (abs(c2-c1) == abs(r2-r1)) ? 1 : 2;
std::cout << steps << std::endl;


Now I have this question in my mind how the ternary operator works and how it's return type is determined (as the compiler called it <unresolved overloaded function type>).










share|improve this question














I was solving a problem about bishop on a chessboard. At one point of my code, I included the following line:



std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


This generates the following error:



error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'


However, I instantaneously fixed this error by including an additional variable in my code:



int steps = (abs(c2-c1) == abs(r2-r1)) ? 1 : 2;
std::cout << steps << std::endl;


Now I have this question in my mind how the ternary operator works and how it's return type is determined (as the compiler called it <unresolved overloaded function type>).







c++ language-lawyer ternary-operator






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 11 hours ago









Meraj al MaksudMeraj al Maksud

5951 gold badge4 silver badges23 bronze badges




5951 gold badge4 silver badges23 bronze badges










  • 2





    I think the ternary operator has precedence over the << operator. And so the first branch of the ternary was 1, and the other 2 << std;:endl

    – Neo
    11 hours ago











  • Look at operator precedence. << is higher than == and ?? (see: en.cppreference.com/w/cpp/language/operator_precedence)

    – ChuckCottrill
    11 hours ago






  • 3





    This also fixes the error: std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;. No need for an intermediate variable.

    – PaulMcKenzie
    11 hours ago












  • Here is an interesting question I found searching through this site before asking here.

    – Meraj al Maksud
    11 hours ago












  • 2





    I think the ternary operator has precedence over the << operator. And so the first branch of the ternary was 1, and the other 2 << std;:endl

    – Neo
    11 hours ago











  • Look at operator precedence. << is higher than == and ?? (see: en.cppreference.com/w/cpp/language/operator_precedence)

    – ChuckCottrill
    11 hours ago






  • 3





    This also fixes the error: std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;. No need for an intermediate variable.

    – PaulMcKenzie
    11 hours ago












  • Here is an interesting question I found searching through this site before asking here.

    – Meraj al Maksud
    11 hours ago







2




2





I think the ternary operator has precedence over the << operator. And so the first branch of the ternary was 1, and the other 2 << std;:endl

– Neo
11 hours ago





I think the ternary operator has precedence over the << operator. And so the first branch of the ternary was 1, and the other 2 << std;:endl

– Neo
11 hours ago













Look at operator precedence. << is higher than == and ?? (see: en.cppreference.com/w/cpp/language/operator_precedence)

– ChuckCottrill
11 hours ago





Look at operator precedence. << is higher than == and ?? (see: en.cppreference.com/w/cpp/language/operator_precedence)

– ChuckCottrill
11 hours ago




3




3





This also fixes the error: std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;. No need for an intermediate variable.

– PaulMcKenzie
11 hours ago






This also fixes the error: std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;. No need for an intermediate variable.

– PaulMcKenzie
11 hours ago














Here is an interesting question I found searching through this site before asking here.

– Meraj al Maksud
11 hours ago





Here is an interesting question I found searching through this site before asking here.

– Meraj al Maksud
11 hours ago












3 Answers
3






active

oldest

votes


















10














This has nothing to do with how the return type is deduced and everything to do with operator precedence. When you have



std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


it isn't



std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


because ?: has lower precedence than <<. That means what you actually have is



std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


and this is why you get an error about a <unresolved overloaded function type>. Just use parentheses like



std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


and you'll be okay.






share|improve this answer
































    6














    You have to put brackets around a ternary operation:



    std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


    If not the the << operator goes to the 2 and it gives an error because it doesn't have such overloaded function.



    This happens because the bitwise left shift operator (<<) has a higher precedence than the ternary operator. You can see the full list of operators and its precedences in the following page of the C++ reference: https://en.cppreference.com/w/cpp/language/operator_precedence






    share|improve this answer










    New contributor



    salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















    • Note: In U.S. English, "brackets" by itself means square brackets, [ ]. "Parentheses" is unambiguously ( ) in all dialects AFAICT.

      – ShadowRanger
      5 mins ago


















    4














    The problem is caused by the



    2 << std::endl;


    part. Due to operatator precedence, that line is treated as:



    std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


    Change it to



    std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;
    // ^----------------------------------^
    // Surrounding parenthesis





    share|improve this answer

























    • std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl; doesn't work. I tried it before posting

      – Meraj al Maksud
      11 hours ago






    • 1





      @MerajalMaksud, that should work. Please post a minimal reproducible example containing that code.

      – R Sahu
      11 hours ago











    • @MerajalMaksud Works just fine here

      – NathanOliver
      11 hours ago











    • Sorry @r-sahu, I actually placed the parenthesis in a wrong way. That's why it didn't work.

      – Meraj al Maksud
      11 hours ago














    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f57400874%2fhow-is-the-return-type-of-ternary-operator-determined%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    10














    This has nothing to do with how the return type is deduced and everything to do with operator precedence. When you have



    std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


    it isn't



    std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


    because ?: has lower precedence than <<. That means what you actually have is



    std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


    and this is why you get an error about a <unresolved overloaded function type>. Just use parentheses like



    std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


    and you'll be okay.






    share|improve this answer





























      10














      This has nothing to do with how the return type is deduced and everything to do with operator precedence. When you have



      std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


      it isn't



      std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


      because ?: has lower precedence than <<. That means what you actually have is



      std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


      and this is why you get an error about a <unresolved overloaded function type>. Just use parentheses like



      std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


      and you'll be okay.






      share|improve this answer



























        10












        10








        10







        This has nothing to do with how the return type is deduced and everything to do with operator precedence. When you have



        std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


        it isn't



        std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


        because ?: has lower precedence than <<. That means what you actually have is



        std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


        and this is why you get an error about a <unresolved overloaded function type>. Just use parentheses like



        std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


        and you'll be okay.






        share|improve this answer













        This has nothing to do with how the return type is deduced and everything to do with operator precedence. When you have



        std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : 2 << std::endl;


        it isn't



        std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


        because ?: has lower precedence than <<. That means what you actually have is



        std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


        and this is why you get an error about a <unresolved overloaded function type>. Just use parentheses like



        std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


        and you'll be okay.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 11 hours ago









        NathanOliverNathanOliver

        111k19 gold badges172 silver badges252 bronze badges




        111k19 gold badges172 silver badges252 bronze badges


























            6














            You have to put brackets around a ternary operation:



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


            If not the the << operator goes to the 2 and it gives an error because it doesn't have such overloaded function.



            This happens because the bitwise left shift operator (<<) has a higher precedence than the ternary operator. You can see the full list of operators and its precedences in the following page of the C++ reference: https://en.cppreference.com/w/cpp/language/operator_precedence






            share|improve this answer










            New contributor



            salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















            • Note: In U.S. English, "brackets" by itself means square brackets, [ ]. "Parentheses" is unambiguously ( ) in all dialects AFAICT.

              – ShadowRanger
              5 mins ago















            6














            You have to put brackets around a ternary operation:



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


            If not the the << operator goes to the 2 and it gives an error because it doesn't have such overloaded function.



            This happens because the bitwise left shift operator (<<) has a higher precedence than the ternary operator. You can see the full list of operators and its precedences in the following page of the C++ reference: https://en.cppreference.com/w/cpp/language/operator_precedence






            share|improve this answer










            New contributor



            salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.





















            • Note: In U.S. English, "brackets" by itself means square brackets, [ ]. "Parentheses" is unambiguously ( ) in all dialects AFAICT.

              – ShadowRanger
              5 mins ago













            6












            6








            6







            You have to put brackets around a ternary operation:



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


            If not the the << operator goes to the 2 and it gives an error because it doesn't have such overloaded function.



            This happens because the bitwise left shift operator (<<) has a higher precedence than the ternary operator. You can see the full list of operators and its precedences in the following page of the C++ reference: https://en.cppreference.com/w/cpp/language/operator_precedence






            share|improve this answer










            New contributor



            salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.









            You have to put brackets around a ternary operation:



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;


            If not the the << operator goes to the 2 and it gives an error because it doesn't have such overloaded function.



            This happens because the bitwise left shift operator (<<) has a higher precedence than the ternary operator. You can see the full list of operators and its precedences in the following page of the C++ reference: https://en.cppreference.com/w/cpp/language/operator_precedence







            share|improve this answer










            New contributor



            salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.








            share|improve this answer



            share|improve this answer








            edited 11 hours ago









            NathanOliver

            111k19 gold badges172 silver badges252 bronze badges




            111k19 gold badges172 silver badges252 bronze badges






            New contributor



            salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.








            answered 11 hours ago









            salccsalcc

            1464 bronze badges




            1464 bronze badges




            New contributor



            salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.




            New contributor




            salcc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

















            • Note: In U.S. English, "brackets" by itself means square brackets, [ ]. "Parentheses" is unambiguously ( ) in all dialects AFAICT.

              – ShadowRanger
              5 mins ago

















            • Note: In U.S. English, "brackets" by itself means square brackets, [ ]. "Parentheses" is unambiguously ( ) in all dialects AFAICT.

              – ShadowRanger
              5 mins ago
















            Note: In U.S. English, "brackets" by itself means square brackets, [ ]. "Parentheses" is unambiguously ( ) in all dialects AFAICT.

            – ShadowRanger
            5 mins ago





            Note: In U.S. English, "brackets" by itself means square brackets, [ ]. "Parentheses" is unambiguously ( ) in all dialects AFAICT.

            – ShadowRanger
            5 mins ago











            4














            The problem is caused by the



            2 << std::endl;


            part. Due to operatator precedence, that line is treated as:



            std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


            Change it to



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;
            // ^----------------------------------^
            // Surrounding parenthesis





            share|improve this answer

























            • std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl; doesn't work. I tried it before posting

              – Meraj al Maksud
              11 hours ago






            • 1





              @MerajalMaksud, that should work. Please post a minimal reproducible example containing that code.

              – R Sahu
              11 hours ago











            • @MerajalMaksud Works just fine here

              – NathanOliver
              11 hours ago











            • Sorry @r-sahu, I actually placed the parenthesis in a wrong way. That's why it didn't work.

              – Meraj al Maksud
              11 hours ago
















            4














            The problem is caused by the



            2 << std::endl;


            part. Due to operatator precedence, that line is treated as:



            std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


            Change it to



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;
            // ^----------------------------------^
            // Surrounding parenthesis





            share|improve this answer

























            • std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl; doesn't work. I tried it before posting

              – Meraj al Maksud
              11 hours ago






            • 1





              @MerajalMaksud, that should work. Please post a minimal reproducible example containing that code.

              – R Sahu
              11 hours ago











            • @MerajalMaksud Works just fine here

              – NathanOliver
              11 hours ago











            • Sorry @r-sahu, I actually placed the parenthesis in a wrong way. That's why it didn't work.

              – Meraj al Maksud
              11 hours ago














            4












            4








            4







            The problem is caused by the



            2 << std::endl;


            part. Due to operatator precedence, that line is treated as:



            std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


            Change it to



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;
            // ^----------------------------------^
            // Surrounding parenthesis





            share|improve this answer













            The problem is caused by the



            2 << std::endl;


            part. Due to operatator precedence, that line is treated as:



            std::cout << (abs(c2-c1) == abs(r2-r1)) ? 1 : (2 << std::endl);


            Change it to



            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl;
            // ^----------------------------------^
            // Surrounding parenthesis






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 11 hours ago









            R SahuR Sahu

            175k12 gold badges103 silver badges202 bronze badges




            175k12 gold badges103 silver badges202 bronze badges















            • std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl; doesn't work. I tried it before posting

              – Meraj al Maksud
              11 hours ago






            • 1





              @MerajalMaksud, that should work. Please post a minimal reproducible example containing that code.

              – R Sahu
              11 hours ago











            • @MerajalMaksud Works just fine here

              – NathanOliver
              11 hours ago











            • Sorry @r-sahu, I actually placed the parenthesis in a wrong way. That's why it didn't work.

              – Meraj al Maksud
              11 hours ago


















            • std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl; doesn't work. I tried it before posting

              – Meraj al Maksud
              11 hours ago






            • 1





              @MerajalMaksud, that should work. Please post a minimal reproducible example containing that code.

              – R Sahu
              11 hours ago











            • @MerajalMaksud Works just fine here

              – NathanOliver
              11 hours ago











            • Sorry @r-sahu, I actually placed the parenthesis in a wrong way. That's why it didn't work.

              – Meraj al Maksud
              11 hours ago

















            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl; doesn't work. I tried it before posting

            – Meraj al Maksud
            11 hours ago





            std::cout << ((abs(c2-c1) == abs(r2-r1)) ? 1 : 2) << std::endl; doesn't work. I tried it before posting

            – Meraj al Maksud
            11 hours ago




            1




            1





            @MerajalMaksud, that should work. Please post a minimal reproducible example containing that code.

            – R Sahu
            11 hours ago





            @MerajalMaksud, that should work. Please post a minimal reproducible example containing that code.

            – R Sahu
            11 hours ago













            @MerajalMaksud Works just fine here

            – NathanOliver
            11 hours ago





            @MerajalMaksud Works just fine here

            – NathanOliver
            11 hours ago













            Sorry @r-sahu, I actually placed the parenthesis in a wrong way. That's why it didn't work.

            – Meraj al Maksud
            11 hours ago






            Sorry @r-sahu, I actually placed the parenthesis in a wrong way. That's why it didn't work.

            – Meraj al Maksud
            11 hours ago


















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f57400874%2fhow-is-the-return-type-of-ternary-operator-determined%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            ParseJSON using SSJSUsing AMPscript with SSJS ActivitiesHow to resubscribe a user in Marketing cloud using SSJS?Pulling Subscriber Status from Lists using SSJSRetrieving Emails using SSJSProblem in updating DE using SSJSUsing SSJS to send single email in Marketing CloudError adding EmailSendDefinition using SSJS

            Кампала Садржај Географија Географија Историја Становништво Привреда Партнерски градови Референце Спољашње везе Мени за навигацију0°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.340°11′ СГШ; 32°20′ ИГД / 0.18° СГШ; 32.34° ИГД / 0.18; 32.34МедијиПодациЗванични веб-сајту

            19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу