Click here to Skip to main content
14,331,758 members

C / C++ / MFC

 
GeneralRe: (C) Robust code Should an unsigned int array index be tested for "< 0" Pin
HS_C_Student17-Jan-19 13:05
memberHS_C_Student17-Jan-19 13:05 
Questionacademic question - usage of class variable Pin
Vaclav_10-Jan-19 5:20
memberVaclav_10-Jan-19 5:20 
AnswerRe: academic question - usage of class variable Pin
Richard MacCutchan10-Jan-19 6:27
protectorRichard MacCutchan10-Jan-19 6:27 
AnswerRe: academic question - usage of class variable Pin
CPallini10-Jan-19 21:28
mveCPallini10-Jan-19 21:28 
GeneralRe: academic question - usage of class variable Pin
Vaclav_11-Jan-19 3:25
memberVaclav_11-Jan-19 3:25 
GeneralRe: academic question - usage of class variable Pin
CPallini11-Jan-19 5:21
mveCPallini11-Jan-19 5:21 
GeneralRe: academic question - usage of class variable Pin
David Crow11-Jan-19 5:44
memberDavid Crow11-Jan-19 5:44 
AnswerRe: academic question - usage of class variable Pin
Stefan_Lang16-Jan-19 22:26
memberStefan_Lang16-Jan-19 22:26 
Generally, if you define a member variable of a class, this variable should only be accessed by member functions of that class (or derived class). This is true both for static and non-static member variables.

If you need to read or change them from outside the class, define accessor member functions as needed.

Any static or non-static function can and may access any member variable. Therefore there is no need to pass it to such a function, unless it is a non-static member variable of a different instance of the class.

Example:

class Vector3i {
private:
   std::array<int,3> data;
public:
   // example 1: change own member variable
   void fill(const int value) {
      data.fill(value);
   }
   // example 2: change member variable from another instance
   void swap(Vector3i& other) {
      std::swap(data, other.data);
   }
};

GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

QuestionChanging CMainFrame Minimize ICON Pin
ForNow9-Jan-19 14:02
memberForNow9-Jan-19 14:02 
QuestionRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 4:07
memberDavid Crow10-Jan-19 4:07 
AnswerRe: Changing CMainFrame Minimize ICON Pin
ForNow10-Jan-19 4:39
memberForNow10-Jan-19 4:39 
GeneralRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 4:42
memberDavid Crow10-Jan-19 4:42 
GeneralRe: Changing CMainFrame Minimize ICON Pin
ForNow10-Jan-19 5:09
memberForNow10-Jan-19 5:09 
QuestionUsage of bitset ? Pin
Vaclav_9-Jan-19 5:12
memberVaclav_9-Jan-19 5:12 
AnswerRe: Usage of bitset ? Pin
Daniel Pfeffer9-Jan-19 5:46
professionalDaniel Pfeffer9-Jan-19 5:46 
AnswerRe: Usage of bitset ? Pin
k50549-Jan-19 6:09
memberk50549-Jan-19 6:09 
GeneralRe: Usage of bitset ? Pin
Daniel Pfeffer9-Jan-19 21:38
professionalDaniel Pfeffer9-Jan-19 21:38 
GeneralRe: Usage of bitset ? Pin
Vaclav_10-Jan-19 4:39
memberVaclav_10-Jan-19 4:39 
QuestionVC++ 2017 redistributables versions. Pin
Maximilien8-Jan-19 4:21
memberMaximilien8-Jan-19 4:21 
AnswerRe: VC++ 2017 redistributables versions. Pin
Victor Nijegorodov8-Jan-19 8:43
memberVictor Nijegorodov8-Jan-19 8:43 
GeneralRe: VC++ 2017 redistributables versions. Pin
Maximilien8-Jan-19 9:01
memberMaximilien8-Jan-19 9:01 
GeneralRe: VC++ 2017 redistributables versions. Pin
Victor Nijegorodov8-Jan-19 9:03
memberVictor Nijegorodov8-Jan-19 9:03 
QuestionSubclassing a listcontrol in dialog bar Pin
manoharbalu6-Jan-19 23:48
membermanoharbalu6-Jan-19 23:48 
AnswerRe: Subclassing a listcontrol in dialog bar Pin
Victor Nijegorodov7-Jan-19 2:12
memberVictor Nijegorodov7-Jan-19 2:12 
Questionupdating output value with timer and resetting if the timer exceeds a certain time or it has a new input value Pin
crucial19536-Jan-19 14:42
membercrucial19536-Jan-19 14:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.