[CTRL++] Initialize member variable in the constructor

 

Initializing values in the constructor is faster than setting them afterwards with setter methods or when defining the variable.

struct S(){  //instead of this, use the constructor  //private b = calcValue();  private b;  public S()  {    b = calcValue();  }};
Date added:
Last revised:
Hits:
7.517
Rating:
Rating: 4.3. 29 vote(s).
29 anonymous votes
No rating done at all.
Your vote was '' (0 of 5) You are an anonymous user.
You may log on to do personalized votings
Click the rating bar to rate this item Please log on to do ratings
  • Notification

    FE user cannot be identified! (1403201096)

Tags:
Programming / Scripting, OOP