#include <iostream.h>
#include <stdio.h>
int main ()
{
int i = 0;
int const& j = i;
int & Const T = i;
const int& m = i;
i = 3;
printf ("j =%d m =%d T =%d i =%d &j =%d &m =%d &t =%d", j,m,t,i,&j,&m,&t);
GetChar ();
}
GCC compilation results:
int & Const T = i; does not pass
#include <iostream>
#include <stdio.h>
int main ()
{
int i = 0;
int const& j = i;
int & Const T = i;
Const int& m = i;
i = 3;
j=4;
m=5;
printf ("J =%d m =%d i =%d &j =%d &m =%d", j,m,i,&j,&m);
GetChar ();
}
GCC compiles the pass-through statement:
i = 3;
j=4;
#include <iostream>
#include <stdio.h>
int main ()
{
int i = 0;
int const& j = i;
int & Const T = i;
Const int& m = i;
i = 3;
printf ("J =%d m =%d i =%d &j =%d &m =%d", j,m,i,&j,&m);
GetChar ();
}
Output:
int const & J = I shows that j is a constant reference to int i, so this means that the value of I cannot be changed by T. However, since I is a variable, I can change the self-born value, and T is a reference to the variable I so she only refers to the value of variable I, so of course I change the value.
about int &const T and int const& t