It’s fine to use either tabs or spaces for indentation (most IDEs have a setting where you can convert a tab press into the appropriate number of spaces).Here are our recommendations for basic formatting: Our basic rule of thumb is that the best styles are the ones that produce the most readable code, and provide the most consistency. Many different methods of formatting C++ programs have been developed throughout the years, and you will find disagreement on which ones are best. Unlike some other languages, C++ does not enforce any kind of formatting restrictions on the programmer (remember, trust the programmer!). Thus doing something like this will get you in trouble: std::cout << "Hello world!" // Here is a single-line comment Single-line comments only last to the end of the line. Quoted text separated by nothing but whitespace (spaces, tabs, or newlines) will be concatenated: std::cout << "Hello "Īnother exception where the C++ compiler pays attention to whitespace is with // comments. Newlines are not allowed in quoted text: std::cout << "Hello And each prints out exactly as you’d expect.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |