What is the difference between declaration and definition?
Answer Posted / rajesh manem
Ans: The declaration is means the memory is not yet all to
be allocated..
For example:
Int a; //is it declaration? Or definition?
Just check this
Int main()
{
Int I;
Printf(ā%dā,i);
}
It prints the garbage value that means the memory is
allocated for this declaration so we can say that this int I
is both declaration and definition.
And take another example extern int I -- declaration
because no memory is allocated.
Similarly for function prototypes all are declarations.
In the case of class declaration String s; // Declaration
[because reference is created]
When the new keyweord encounters then it is definition
String *s=new Stirng(); //declaration and
definition
| Is This Answer Correct ? | 38 Yes | 4 No |
Post New Answer View All Answers
What is the diamond problem in inheritance?
How do you achieve runtime polymorphism?
What is the full form of oops?
What is abstraction oop?
Why is abstraction needed?
What is multilevel inheritance in oop?
What is the renewal class?
What is inheritance in oop?
Can static class have constructor?
How do you define social class?
What is the importance of oop?
Write a c++ program to display pass and fail for three student using static member function
Can we define a class within the interface?
What is super in oop?
What is the difference between a constructor and a destructor?