Using Code::Blocks IDE for Mac in my C++ class, I’m spending some time trying to clean up my first lab with comments and the like, and the syntax highlighting alerted me to something I can’t seem to find documentation over online.
/**
Author: Name
Lab1
Purpose: simulate a calculator with informative menu
*/
has a different highlighting color than simply
/*
What I thought
a normal multiline comment
was...
*/
and even different still from
// Models a basic calculator with looping menu until sentinel or invalid operator is given
I’m curious as to what the purpose/function is to the first code snippet. In Java, this is a docstring. Does it serve the same purpose in C++? If not, what is it, and how is it conventionally used?
The first is a comment that Doxygen will recognize as documentation. Doxygen is modeled after Javadoc. And it’s rather popular, so it’s not surprising that Code::Blocks recognizes it. Doxygen can generate output in a wide variety of formats, including straight HTML that can be viewed with a web browser.
I don’t know why it decided that the 2nd and 3rd examples should be a different color. Maybe because one is a block comment and another is ‘until the end of line’ comment. But that seems like a somewhat trivial distinction to me.