initialization
int x{}; // x is filled with zeroes, so x == 0
int x{123};
int x(123);
int a, b = 123, c{}, d{456}, e(789);
int* x, y, z; == int* x; int y; int z;
int *x, y, *z
Reference
C++ has two kinds of references: “lvalue” and “rvalue.” Just like with pointers, these are an annotation on another type:
we must initialize lvalue references and rvalue references when they are declared.
int a = 1;
// lvalue references
int& x = a;
int & x = a;
int &x =a;
// rvalue references
int&& x=a;
int && x=a;
int &&x=a;
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/280961.html