简体   繁体   中英

comments in C++ in Sublime Text 2

I'm trying to write some C++ in Sublime Text 2. If I begin a line with a double forward slash (//) the text in that line grays out as if it were commented out, but it causes a build error when I compile, so clearly it isn't. If I begin the line with a pound sign (#) that line is commented out but doesn't change in appearance. I want to be able to tell what lines are comments and what lines are actually part of my program. How is this done?

In c++ comments look like this

// one line comment or
/* comment
   over multiple
   lines */

If your compiler is not recognizing these, chances are, it's not compiling c++. This seems even more likely seeing how lines beginning with # will be ignored like you'd expected for some other languages (for example python)

Make sure to check what the "build" button in your IDE actually calls/does.

You can try this:

/*
I am a comment!
I am another comment!
*/

I hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM