Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three forward slashes for block commenting?

Tags:

c++

First noticed this in Notepad++, where // comments and /// comments were shown in different colours.

Doxygen revealed 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?
like image 561
Nav Avatar asked Feb 08 '12 03:02

Nav


3 Answers

  1. Surely, its easier to hit the same key thrice than hitting two separate keys.
  2. 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.

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.

like image 177
Carl Avatar answered Oct 21 '22 23:10

Carl


In Visual Studio the /// indicates documentation not 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.

like image 29
linuxuser27 Avatar answered Oct 22 '22 01:10

linuxuser27


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.

  1. ///
  2. //!
  3. /** */
like image 10
grokus Avatar answered Oct 22 '22 01:10

grokus