Umubyeyi137 Umubyeyi137
  • 18-05-2018
  • Computers and Technology
contestada

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

Respuesta :

tonb
tonb tonb
  • 18-05-2018
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
Answer Link

Otras preguntas

In Franz Kafka’s The Metamorphosis, why does the protagonist dislike his job? A. Because he prefers to stay home and listen to his sister play the violin B. Be
Why is 1/8 greater than 1/10 but less than 1/3?
What are two reasons why Germany finally surrendered during World War I?
You see red flower when
why was the capital of South Carolina moved from Charleston to Columbia
What is one piece of evidence that caused Wegener to think that continents moved? A. He found an old map of the world that showed movement, B. He found similar
Which group was not a target of the ku klux klan
Rachel wants to improve her body composition by reducing her BMI. She swims with her friends after school two days a week and eats a well-balanced diet. What el
One reason that the colony of New Netherland grew slowly was that
The invasion of Laos was the first test of _____. Operation Rolling Thunder total containment Operation Tonkin Vietnamization