Meaning: Defining a variable means creating it. It's crucial to create a variable before using it.
Syntax:
data_type variable_name;
char grade;
int
, char
, float
).Purpose:
Meaning: Declaring a variable involves telling the compiler about the variable's properties without allocating memory.
Purpose: Indicate that a variable is defined elsewhere in a project, especially important in multi-file projects.
Syntax:
extern data_type variable_name;
extern char grade;
extern
keyword implies the variable is defined outside the current file.This lecture covered the basic concepts of variables in C++—defining and declaring variables—and emphasized their importance in programming.