我需要解释这个代码,它的意思是&在C ++中? [英] I need explanation of this code and what does it mean by & in C++?

查看:136
本文介绍了我需要解释这个代码,它的意思是&在C ++中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

enum xyz
{
  a, 
  b, 
  c
};

int main()
{
  int x = a, y = b, z = c;
  int &p = x, &q = y, &r = z;

  p = z;
  p = ++q;
  q = ++p;
  z = ++q + p++;

  cout<< p << " " <<; q << " " << z;

  return 0;
}





我的尝试:



---



What I have tried:

---

推荐答案

代码使用参考声明 - cppreference.com [ ^ 。它是C中不存在的基本C ++语言功能。另请参见标准C ++:参考 [ ^ ]。
The code uses Reference declaration - cppreference.com[^]. It is a basic C++ language feature that does not exist in C. See also Standard C++: References[^].


没有什么神秘的代码...所有你需要做的就是通过你的调试器逐行,逐个命令地运行它...
There is nothing mysterious about that code... All you have to do to understand it is run it via your debugger line-by-line, command-by-command...


这篇关于我需要解释这个代码,它的意思是&amp;在C ++中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆