What is the difference between declaration and definition?
With example can someone explain this?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jan 23, 2013, 12:58 PM EST
http://msdn.microsoft.com/en-us/library/0e5kx78b.aspx
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 23, 2013, 5:43 PM EST
Declaration: it means that something is declaring such as a class, function or variable. You don't say anything about what that class or function looks like, you just say that you will say what it looks like.we can say This function or this variable exists somewhere, and here is what it should look like.
Definition: You define how something is implemented, such as a class, function or variable, i.e. you say what it actually is.we can say says: "Make this variable here" or "Make this function here."
example Delegate is Declaration where as event is Defination.
hope this will help you.Rishikesh Kumar SinghRank #1,250 · 1.4K reputationPosted Jan 23, 2013, 9:50 PM EST
Ex-
public int sum(int,int);
Here i have declared one method namely sum whose nature is that it will take two arguments of integer type an it will return one integer type value.
Definition: Definition means specifying the functionality of our function. Defining means to provide a body to a function that what our function is going to do.
Ex-
public int sum(int a,int b)
{
return(a+b); //it will find the sum of two numbers
}
Sam HobbsRank #107 · 20.5K reputationPosted Apr 5, 2013, 12:02 PM EDT
A definition is memory allocated and initialized based on a declaration.
Note that it is also very confusing to attempt to differentiate the two for fundamental types. In other words, plain types such as "int" have implicit declarations.
Also note that the PHP language is very confused. The implementers of that language misuse the terms horribly. The C++ language standard is consistent with the explanation above.
Sharad RathoreRank #3,483 · 416 reputationPosted Jul 3, 2013, 6:51 PM EDT
2. Identifies Data Type.
3. Re-Declaration is Error.
Definition :- 1. In Definition Space is reserved.
2. Some initial value is assigned.
3. Re-Definition Error.
Regards,
sharad kumar rathore