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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sharad RathorePosted Jul 3, 2013, 10:51 PM
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
Sam HobbsPosted Apr 5, 2013, 4:02 PM
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.
Rishikesh Kumar SinghPosted Jan 24, 2013, 2:50 AM
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
}
Jignesh TrivediPosted Jan 23, 2013, 10:43 PM
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.VulpesPosted Jan 23, 2013, 5:58 PM
http://msdn.microsoft.com/en-us/library/0e5kx78b.aspx