Reference review
#include <iostream>
using namespace Std;
void Show1 ()
{
cout << "Show1" << Endl;
}
void Show2 ()
{
cout << "Show2" << Endl;
}
void Show3 ()
{
cout << "show3" << Endl;
}
int main ()
{
int one = 1;
int &r1 (one); Lvalue reference, referenced memory entity
int &&r2 (one+1);//rvalue reference, value in reference register
int &&r3 (Move (one));//move can refer to Lvalue as Rvalue
cout << One << "<< R1 <<" "<< R2 <<" "<< R3 << Endl;
int: 1;
int* p (&two);
int* (&RP) (p);//reference form of a first-level pointer
int** pp (&p);
Int (* * (&RPP)) (PP); The reference form of the second level pointer
int* && Temp (&two); The address of the variable is the right value, with an rvalue reference
cout << *rp << "<< **rpp << Endl;
void (*a) () (SHOW1); function pointers
A ();
void (*&AA) () (a); function pointer Reference
AA ();
void (*ra[3]) () {show1, show2, show3}; Array of function pointers on the stack
for (auto I:ra)
{
I ();
}
void (* (&rra) [3]) (RA); Array of function pointers on the reference stack
for (auto I:rra)
{
I ();
}
void (**raa) () = new (void (*[3)) ()) {show1, show2, show3}; Array of function pointers on the heap
for (int i = 0; i < 3; i++)
{
Raa[i] ();
}
void (* * (&RRAA)) (RAA);
for (int i = 0; i < 3; i++)//reference to the array of function pointers on the heap
{
Rraa[i] ();
}
return 0;
}
C + + Reference review