Lesson 34 of 45 · C++
Lesson 4: Variables and Data Types
Duration: 9 min
Lesson 34 of 45 · C++
Duration: 9 min
bool, char, signed/unsigned int, short, long, long long.\n- Floating‑point – float, double, long double.\n- Character – char (signed or unsigned depending on implementation) and char16_t, char32_t, wchar_t.\n- Boolean – bool with literals true and false.\n\nC++ also offers type inference via auto and type traits through <type_traits>.\n\n---\n\n## Example: Declaring and Initialising\ncpp\nint i = 42; // explicit type\nauto f = 3.14; // deduced as double\nunsigned long long big = 1ULL; // suffix U for unsigned, LL for long long\nbool flag = true; // boolean literal\n\n\nUse sizeof to query the byte size of a type:\ncpp\nstd::cout << \"Size of int: \" << sizeof(int) << \" bytes\\n\";\n\n\n> Tip: Prefer uniform initialisation (int x{5};) to avoid narrowing conversions.\n\n---\n\n<Alert type="info">auto does not mean dynamic typing; the type is still fixed at compile time.