Ask Question
11 June, 22:02

How to separate a local and private variable of the same name c++?

+2
Answers (1)
  1. 11 June, 22:20
    0
    If you have a private class variable, say private int a; and a local function variable int b; then a and b can be used in that function in the same way, you can't spot the difference. A couple of conventions exist to make this more visible in your program:

    - prefix the class member variables with something like m or m_ (just an underscore is done in c# but you can run into clashes with reserved names in c++)

    - always dereference them with this->a
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How to separate a local and private variable of the same name c++? ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers