在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