C++ beginner(2)- variable


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

(0)
上一篇 2022年8月17日
下一篇 2022年8月17日

相关推荐

发表回复

登录后才能评论