简体   繁体   English

我不明白结果

[英]I don't understand result

在此处输入图片说明

I thought result will be int parameter a : 3 3我认为结果将是 int 参数 a : 3 3

but result was但结果是

在此处输入图片说明

why result is it?结果是为什么?

Where you call "cout << "int\\t" << TestFunction(3) << endl;"你在哪里调用“cout <<”int\\t” << TestFunction(3) << endl;” it needs to evaluate the function call first, before it can print out "int\\t (returned value)" The only way it will know what to print out is by running the function.它需要先评估函数调用,然后才能打印出“int\\t(返回值)”。它知道要打印什么的唯一方法是运行该函数。 When the function runs, it prints out "paramater a :".当函数运行时,它会打印出“paramater a :”。 The three is then returned, and the second cout statement can be performed: (int\\t)然后返回三个,就可以执行第二条cout语句了:(int\\t)

Ready steps准备步骤

  1. Ready to Print : "int (value)"准备打印:“int(值)”
  2. TestFunc is called. TestFunc 被调用。
  3. "parameter a: 3" is printed.打印“参数a:3”。
  4. TestFunc returns value "3" TestFunc 返回值“3”
  5. Ready to Print : "int (value)" --> Print : "int 3"准备打印:“int(值)”--> 打印:“int 3”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM