explain the code below?


using namespace std;

int &bigger(int&,int&);

int main()


 int x,y;





 return 0;


int &bigger(int&a,int&b)



 return a;


  return b;


1 Answer

  • EddieJ
    Lv 7
    1 month ago

    This is very unusual code and I've never seen anyone doing anything like this before.

    bigger () returns a pointer to an integer.  Since the arguments to bigger () are passed by reference (because of the & in the parameter list), it returns a pointer to one of them, specifically, the one that points to a larger value.

    In this case, the second argument points to a larger value, so


    assigns 20 to the second argument, y.

    Offhand, I can't think of a practical reason to do this.

    • Commenter avatarLog in to reply to the answers
Still have questions? Get answers by asking now.