Passing by Reference
void main()
{ void centimise(double&);
double var = 10.0;
cout <<endl<< ‘var = ‘<<var<<’inches’;
centimise(var);
cout <<endl<<’var = ‘ <<var<<’centimeters’;
}
void centimise(double& v)
{
v *= 2.54; //v is the same as var
}
Previous slide
Next slide
Back to first slide
View graphic version