When working with native c++ in Visual Studio, intellisense shows private members and functions even when outside the scope of the containing class. This makes it hard to create clean APIs for the classes I write.
Is there a reason for this? Can this be prevented?
Ctrl + Space should do it.
IntelliSense is a code-completion aid that includes a number of features: List Members, Parameter Info, Quick Info, and Complete Word. These features help you to learn more about the code you're using, keep track of the parameters you're typing, and add calls to properties and methods with only a few keystrokes.
Well, why shouldn't it show the private ones as well? They are members, after all, they exist and they are perfectly accessible from certain contexts, just like any other members.
It would be very difficult for the IntelliSense to determine whether the members are accessible or not from this specific context, especially if you take into account that in most cases this context is not yet complete (the user is still typing it up), meaning that it is generally impossible to analyze it.
The reason probably only Microsoft knows. (I think Intellisense doesn't check where you are at the moment, so it doesn't know if you are inside the class (and can access the private members) or outside)
I actually don't know if or how it can be prevented.
But as far as I know, they have an Icon with a lock so you know that they are private. Perhaps that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With