Ask Question

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

+5
Answers (1)
  1. 22 July, 12:46
    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?
Find an answer to your question 👍 “How to separate a local and private variable of the same name c++? ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers