Is there a way to detect (for instance with compiler warning) if classes are declared friend but do not access private members, ie. when friendship is useless?
Is there a way to detect (for instance with compiler warning) if classes are
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Compiler warnings are not standardised, so this depends on your specific compiler(s). I would be very surprised if any of them supported this, however. A similar situation would be if you had a public member function which was only called by other public members (meaning it needn’t be public), and once again I don’t think any compilers detect this.
Doing either of these tests would mean extra work for the compiler writers, and I doubt if they would see them as sufficiently useful to implement.