Unused friend class in C ++

Is there a way to detect (for example, with a compiler warning) if the classes are declared friendbut do not have access to private members, i.e. when is friendship useless?

+5
source share
4 answers

Compiler warnings are not standardized, so it depends on your specific compiler (s). However, I would be very surprised if any of them supported this. A similar situation would be if you had an open participant function that was called only by other public members (which means that it should not be publicly available), and once again I do not think that any compilers detect this.

, , .

+3

, , - friend class /*friend*/ class , , , .

+6

, . , , . , , .

+2

, , , 'friend' (, sed) , .

0
source

All Articles