this in reference c++. question have goes 6 months, when used think declaration was:
int a;
and definition was:
a = 5;
also, that:
int = 5;
was both declaration , definition.
i've come understand that:
int a;
is definition, not declaration. (i don't know why).
also, there terms such assigning, , initialising add further jargon issue.
so here current understanding (and please correct anything):
int a; // declaration , definition int = 5 // declaration, definition, assignation , initialisation. = 5; // initialising (if first time), // assigning (if subsequent times), // defining (not sure one).
i have read quite bit on topic still confused. can explain each is? know in such cases there philosophical disputes, 0 number, or number. haha, can try? thanks.
a declaration may introduce 1 or more names translation unit or redeclare names introduced previous declarations.
a definition declaration in specific circumstance. (ie, declaration initializer). because have meet 1 definition rule. definitions declarations, not vice-versa.
initialization gives initial value variable in definition. initialization happens in other situation (eg. function argument passing)
assignment used assign new value existing object.
in specific case
int a; // definition, default-initialization if it's local, zero-initialization otherwise int = 5; // definition, copy-initiaization = 5; // assignment
also, following declaration not definition
extern int i; // declaration not definition
Comments
Post a Comment