Hello all,
I am despondent to handle difference between declaration and definition of a variable. I have been totally confused.
Please help me,
Thanx in advance
Suyash
Declaration of a variable is stating that it exists.
Definition of a variable says it exists and it is here, thus it implies that it is declared.
That doesn't only relate to variables but functions, structs/classes. enums... did I forget anything?
The following are declared but not defined:
-
extern int var;
-
void function();
-
struct myStruct;
-
class myClass;
-
enum myEnum;
-
The following are defined:
-
int var;
-
void function()
-
{
-
}
-
-
struct myStruct {
-
// stuff in here
-
};
-
-
class myClass {
-
// stuff in here
-
};
-
-
enum myEnum {
-
// stuff in here
-
};
-
Hope that helps.
Adrian