如何隐藏课程的私人成员? [英] How to hide private members of a Class?

查看:180
本文介绍了如何隐藏课程的私人成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用visual studio一段时间,当我使用Classes时,它使我厌烦。问题是,当我创建一个类的对象,我倾向于看到私有成员属于那个类,我不想,因为如果我创建一个具有10+私有变量的类,那么它将是一个噩梦,必须有办法隐藏私人会员,
如果有办法可以与我分享吗?
谢谢:)

I've been using visual studio for some time and it annoys me everytime when I work with Classes. The problem is, when I create an object of a Class I tend to see the private members belongs to that class and I don't want to, because what if I create a class with 10+ private variable, then it will be a nightmare, there must be a way to hide private members, If there is a way could you please share it with me? Thank you :)

编辑:

这里有一张照片,我在说,

Here is a picture that will help you understand what I'm talking about,

例如在这里我有2个私有变量的LinkedList类(curSize和头)我将无法改变他们从主要所以,没有点看到他们(是有?)
我如何隐藏它们而不改变我的代码?在Visual Studio中有一个设置?

for example here I have 2 private variables of LinkedList class (curSize and head) I won't be able to alter them from main so, there is no point seeing them(is there?) How can I hide them without altering my code? is there a setting for that in Visual Studio?

推荐答案

不幸的是,这是不可能在当前版本的Visual Studio。在C ++中,IntelliSense列表不会被辅助功能或范围过滤。因此,即使在实际上您的代码无法访问私有成员,仍会显示。没有设置可以调整此行为。

Unfortunately, this is not possible in the current version of Visual Studio. In C++, the IntelliSense list is not filtered by accessibility or scope. Therefore, private members are still shown even where they are not actually accessible by your code. There are no settings to tweak this behavior, either.

您只需依靠锁定图标指示它们是私有的,因此无法访问。智能感知窗口中的所有小图标( 都有意义,你知道。

You just have to rely on the lock icon to indicate that they're private and therefore inaccessible. All of those little icons in the IntelliSense window do have a meaning, you know.

但是,看起来这个功能可能会在下一个版本的Visual Studio(VS11)。 MSDN说

But it looks like this feature might be coming in the next version of Visual Studio (VS11). MSDN says:


列出成员增强功能。当您在代码编辑器中键入代码时,列表成员下拉列表会自动出现。过滤结果,以便在您键入时只显示相关成员。您可以在文本编辑器,C / C ++,高级下的选项对话框中控制成员列表使用的过滤逻辑的类型。

List Members Enhancements. The List Members drop-down appears automatically as you type code into the code editor. Results are filtered, so that only relevant members are displayed as you type. You can control the type of filtering logic used by the Member List in the Options dialog box under Text Editor, C/C++, Advanced.

就这么简单,我也很激动。与其他酷的东西,如更好的语法高亮和参考高亮。 开发人员预览已经发布,因此您可以尝试开始使用它想要,但它可能没有准备好黄金时间。这是不可否认的一种糟糕的理由升级...

As silly as it is, I'm rather excited about this, too. Along with other cool stuff like better syntax highlighting and reference highlighting. The Developer Preview is out already, so you could try to start using it if you want, but it may not be ready for prime time. And this is admittedly kind of a lousy reason to upgrade...

或者,您可以投资 Visual Assist X ,它是一个可用于多个版本的Visual Studio的扩展,它为C ++ IDE增加了许多方便的功能,并相应地改进了IntelliSense过滤。它不是免费的,但它对于C ++开发人员来说是非常棒的,如果我不是穷人/破旧/便宜,我肯定会自己购买。

Alternatively, you could invest in Visual Assist X, which is an extension available for multiple versions of Visual Studio that adds a lot of convenience features to the C++ IDE and, pertinently, improves the IntelliSense filtering. It's not free, but it's pretty awesome for C++ developers, and if I wasn't poor/broke/cheap, I'd definitely buy it myself.

这篇关于如何隐藏课程的私人成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆