評論#
介紹#
C++中的註解用於在程式碼中新增解釋或說明。它們不會影響程式碼的運作方式,可用於闡明邏輯、記錄功能或暫時停用部分程式碼。
Comments#
單行註解以 // 開頭,一直持續到行尾。
// This is a single-line comment
printf("Hello!"); // Print a greeting message
// Print a greeting and then a farewell
printf("Hello!");
printf("Goodbye!");
Multiline Comments#
C++ 使用區塊註解(/* … */)來解釋多行程式碼。這些是真正的註釋,會被編譯器忽略。
/*
This project prints a greeting message,
followed by a farewell message
*/
printf("Hello!");
printf("Goodbye!");