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

What is the difference between declaration and definition of function or variable

22nd Jun 2021, 8:09 PM
Chaitanya Kumar
Chaitanya Kumar - avatar
2 Answers
+ 2
The declaration provides the basic properties of a symbol: its type and its name. The definition provides all the details of that symbol - if it's a function, what it does; if it is a class, what fields and methods it has; if it's a variable, where is that variable located.
22nd Jun 2021, 8:34 PM
SammE
SammE - avatar
+ 1
Martin Taylor I thought that declaration is just naming and specifying data type of function or variable and definition is loading that function or variable into memory. But in C programming we don't have to define and declare identifier separately. C define and declare with just one expression. int MyNum; //This will define and declare at same time. MyNum = 1234; //Initialization of identifier.
23rd Jun 2021, 8:23 AM
🌀 Shail Murtaza شعیل مرتضیٰ
🌀 Shail Murtaza شعیل مرتضیٰ - avatar