c++ - Pass by Reference Address passing issue -


this question has answer here:

#include<iostream> using namespace std;  void callbyreference (int &);    //function prototype  int main() {   int num;                         //variable declaration   cout<<"enter number";    cin>>num;   callbyreference(num);             //function definition   cout<<"number after triple "<<num<<endl;   return 0; }  void callbyreference (int & cref)   //funciton definition {   cref=cref*cref*cref; } 

if passing address in cref address should multiplied thrice. how value multiplied thrice?

you have reference variable argument, variable altered , not address itself. reference variable alias actual variable , changes made reflect in changes made original variable in case


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -