Program comments เป็นคำอธิบายที่คุณสามารถใส่ในโค้ด C++ ช่วยให้ผู้อ่านซอร์สโค้ดเข้าใจง่ายขึ้น ทุกภาษาโปรแกรมมิ่งอนุญาตให้มี comments บางรูปแบบ
C++ รองรับ single-line และ multi-line comments ตัวอักษรทุกตัวภายใน comment จะถูกคอมไพเลอร์ C++ ไม่สนใจ (ignored)
Single line comments
เพื่อสร้าง single line comment ใช้ // notation ที่ไหนต้องการเริ่ม comment เริ่มด้วย // ตัวอย่าง -
// This is a comment cout<<"Hello"; // This is a comment following a statement.
Multiline comments
Multiline comments ครอบหลายบรรทัด เรียกว่า block comments ใช้ /* */ notation ตัวอย่าง -
/* This is a Multiline comment */