C++ 用于块评论的三个正斜杠?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9187616/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Three forward slashes for block commenting?
提问by Nav
First noticed this in Notepad++, where //
comments and ///
comments were shown in different colours.
Doxygenrevealed more about it, but I'm not convinced about its efficacy.
1. Why would anyone use the three slashing commenting style when it's far easier to type /*
and */
? (I figure there has to be a better explanation than it being useful when nesting comments)
2. For it to be usable, do editors support block commenting for triple slashes in the way that Visual Studio has support for Ctrl+k Ctrl+c
for multi-line comments?
首先在 Notepad++ 中注意到这一点,其中//
注释和///
注释以不同的颜色显示。
Doxygen透露了更多关于它的信息,但我不相信它的功效。
1. 为什么有人会使用三个斜线的评论风格,因为它更容易打字/*
和*/
?(我认为必须有一个更好的解释而不是在嵌套注释时有用)
2. 为了使它可用,编辑器是否像 Visual Studio 支持Ctrl+k Ctrl+c
多行注释那样支持对三重斜杠的块注释?
回答by linuxuser27
In Visual Studio the ///
indicates documentationnot just comments. Following your link the explanation is the same. It is used to adorn comments that will be specifically formatted via your editor or some other tool as documentation for a class, method, namespace, etc.
在 Visual Studio 中,///
指示文档而不仅仅是注释。按照您的链接,解释是相同的。它用于装饰注释,这些注释将通过您的编辑器或其他一些工具专门格式化为类、方法、命名空间等的文档。
回答by grokus
The author might intend to put documentation after ///
作者可能打算将文档放在 /// 之后
At where I work, we use 3 styles of doxygen comment blocks for documentation because lack of coding style guidelines.
在我工作的地方,由于缺乏编码风格指南,我们使用 3 种风格的 doxygen 注释块作为文档。
- ///
- //!
- /** */
- ///
- //!
- /** */
回答by Carl
- Surely, its easier to hit the same key thrice than hitting two separate keys.
- Don't know about other IDEs, but XCode4 supports code snippets where you can type pretty much anything. On Visual Studio, I use Visual Assist X, which gives me the same thing. XCode4 Example,Visual AssistX example. I'd have to assume other IDEs provide similar functionality.
- 当然,按三次相同的键比按两个单独的键更容易。
- 不知道其他 IDE,但 XCode4 支持代码片段,您可以在其中键入几乎任何内容。在 Visual Studio 上,我使用 Visual Assist X,它给了我同样的东西。XCode4 示例,Visual AssistX 示例。我不得不假设其他 IDE 提供类似的功能。
That said, yes I have come across triple slashes too and they are generally used to indicate comments that an auto-documentation system like doxygen would pick.
也就是说,是的,我也遇到过三重斜线,它们通常用于表示像 doxygen 这样的自动文档系统会选择的评论。