Ask Question
31 May, 14:25

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

+4
Answers (1)
  1. 31 May, 16:49
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers