”工欲善其事,必先利其器。“—孔子《论语.录灵公》
首页 > 编程 > ##为什么我的温度值存储在数组中,而不是我的C ++类中的预期变量?

##为什么我的温度值存储在数组中,而不是我的C ++类中的预期变量?

发布于2025-03-22
浏览:491

## Why is my temperature value being stored in the array instead of the intended variable in my C   class? 
在c

Problem: Shadowing in a Class

Consider the following class definition:

class Measure { int n; double measure_set []; char nomefile []; 双t; 民众: void get(); void printall(); 双平均值(); double thermal_comp(); }; ; if(f.eof())休息; m; } f.close(); n = m 1; cout > t; cout 在这种情况下,t变量在get方法阴影中声明class成员变量t。

避免阴影,您可以使用不同的名称使用不同的名称,或者使用范围分辨率运算符(:::::::)显式参考类成员变量的范围。此:

; if(f.eof())休息; m; } f.close(); n = m 1; cout >温度; t =温度; cout ; if(f.eof())休息; m; } f.close(); n = m 1; cout > this-> t; //使用示波器分辨率操作员参考类成员变量 cout
最新教程 更多>

免责声明: 提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发到邮箱:[email protected] 我们会第一时间内为您处理。

Copyright© 2022 湘ICP备2022001581号-3