Every programming language has strict grammatical rules called Syntax. C++ syntax is case-sensitive, whitespace-flexible, and statement-driven (terminated with semicolons ;). Let us dissect every single line of a standard C++ program to understand how each piece functions.
// Line 1: Preprocessor Directive to include the Input/Output Stream library
#include <iostream>
// Line 2: The Main Entry Point Function
int main() {
// Line 3: Output stream statement using the standard namespace
std::cout << "Hello, Veewom C++ Student!" << std::endl;
// Line 4: Return status code 0 to the Operating System
return 0;
}
#include <iostream>: Tells the preprocessor to load the standard Input/Output library header containing declarations for std::cout, std::cin, and std::endl.int main(): The mandatory starting point (entry point) for every standalone C++ program. Execution begins and ends here.{ ... }: Curly braces define a code block and establish variable scope.std::cout: The standard character output stream object. std is the namespace, and :: is the scope resolution operator.<<: The Stream Insertion Operator. It directs whatever is on its right side into the output stream on its left.std::endl: Inserts a newline character (\n) AND forces the output stream buffer to flush to the screen immediately.return 0;: Terminates the main function and sends status code 0 (success) back to the OS process supervisor.A Token is the smallest individual building block in a C++ program recognizable by the compiler. There are 5 primary categories:
| Token Category | Explanation | Examples |
|---|---|---|
| Keywords | Reserved words with fixed predefined meanings | int, class, public, virtual, auto, return |
| Identifiers | Programmer-defined names for variables, functions, and classes | studentAge, calculateTotal, Player |
| Literals / Constants | Fixed data values directly written in source code | 100, 3.14159, 'A', "Veewom", true |
| Operators | Symbols that trigger mathematical or logical computations | +, -, *, /, &&, ||, <<, >> |
| Punctuators / Delimiters | Characters that organize and structure the code | ;, { }, ( ), [ ], , |
Boost your C++ proficiency by studying these closely connected core modules:
Deep dive into cin, cout, cerr, and stream formatting.
Variable declarations, naming conventions, and scopes.
Writing clear comments and Doxygen documentation.