Is it difficult to omit the private keyword from the class definition?

I recently deleted the privateone specified in the class definition because it was on top, right after the keyword class:

class MyClass
{
private:
    int someVariable;
// ...

I thought it was superfluous.

The employee disagreed, stating that he had effectively β€œhidden” the nature of the data private.

Most of our legacy codes explicitly specify access specifiers, and they are usually mixed inconsistently with them throughout the definition. Our classes are also very large.

I am trying to make my new classes small enough so that my class definitions look like:

class MyClass
{
    // 3-4 lines of private variables
protected:
    //  3-4 lines of protected functions
public:
    //  public interface
}

, (), private struct/class .

struct/class?

+5
7

, , , , , .

, , , 100% . , , . .

, , , , , , .

+9

, "private" "public" , , . . " ", " " .., :

class A
{
public: // methods
private: // methods
private: // attributes
};

, , . , "" , . , . "public" "".

+4

- , ; ++ , , .

: , , , .

+1

, - . - , , .

, ( , , "" , ). , private:, -.

+1

, private , . , , .

, .

0

: , . , . , , .

, , , . , , (, ).

0

/, / .

, , , .

struct? public ...

However, there is never too much clarity about what is happening in your code. This is the same reason I avoid the ternary operator and still put in braces for the if statement, which has only one line of code.

The most pressing issue, however, what are the standards of your standards for companies? Like them or not, this standard style that you have to do for your company, if they say do it this way, you do it that way.

0
source

All Articles