C++ beginner(2)- variable

2022/8/17 1:52:48

本文主要是介绍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;


这篇关于C++ beginner(2)- variable的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程