Hi,
Could someone give me a good use case, the rationale, for hiding data members
http://melpon.org/wandbox/permlink/mXshdsg9A3dY53Jn
I understand that the language allows shadowing a variable in an inner scope of a function, but hiding base data members seems to me more risky.
In the same way we have override when we are overriding a virtual function and we will get an error if there is no virtual function to override, we could have some kind of "hide" data member. The compiler could then report a warning when the data member is hidden without an explicit "hide".
I believe the same could apply to hidden overloaded functions.
Vicente
3) implementations already warnCould you tell me which flags I need with gcc or clang to get a warning in this case.
Wow, sorry for trying. I used that to reveal some warnings about shadowing in certain scopes, where I can't currently be sure whether those included member variables, and although I couldn't test it right now thought I'd post it in case it included class members and would be useful.
On Thursday, 12 January 2017 07:12:11 UTC, D. B. wrote:
Wow, sorry for trying. I used that to reveal some warnings about shadowing in certain scopes, where I can't currently be sure whether those included member variables, and although I couldn't test it right now thought I'd post it in case it included class members and would be useful.
For the record: -Wshadow (clang, gcc, icc) and C4458 (MSVC) warn on local variables shadowing various names including class non-static data members. They do not warn on derived class NSDMs shadowing base class NSDMs.
Thanks, this is what I was aware of.
At the risk of throwing some cold water on the thread, I think that if compiler vendors are not supplying warnings for derived-base NSDM shadowing/hiding that suggests that it is not considered much of a problem in practice.