What is the difference between declaration and definition of a variable and function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between declaration and definition of a variable and function?

its common to differentiate lets see how many can guess right

10th Mar 2018, 5:02 PM
Mayur Shetty
Mayur Shetty - avatar
2 Answers
+ 6
When you declare a variable and let it be nil, this is called declaration. When you assign some value to variable it becomes definition.
10th Mar 2018, 5:18 PM
Pravin Pandey
Pravin Pandey - avatar
+ 3
Declaration of a variable is the action to require a memory address pointer in the memory stack without assign a primitive type and value related. Definition is the action to bind that variable (memory address related) to a primitive type (e.g int) and value (e.g. 1)
10th Mar 2018, 8:34 PM
s1m0ne
s1m0ne - avatar