ReSharper 2024.1 Help

Code inspection: Access specifier does not change accessibility level

Category

Redundancies in Code

ID

CppRedundantAccessSpecifier

EditorConfig

resharper_cpp_redundant_access_specifier_highlighting

Default severity

Hint

Language

C++

This inspection notifies you about access specifiers that have no effect on the semantic of the program.

In the example below, the second and third public: would be grayed out because they follow the first public: without any other specifiers in between. So in effect you can remove them to improve readability without changing the meaning of your program.

class Person { public: int age; public: //Access specifier does not change accessibility level string name; public: //Access specifier does not change accessibility level int gender; }

Note that even the first access specifier could be redundant if there is the same access specifier in a macro expansion that precedes it.

Last modified: 11 February 2024