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


Please Help Members By Posting Answers For Below Questions

What are the 4 main oop principles?

668


What is polymorphism used for?

564


Give an example where we have to specifically use C programming language and C++ programming language cannot be used?

1135


What is oops in programming?

558


Can a destructor be called directly?

591






What is the highest level of cohesion?

566


hi, this is raju,iam studying b.tech 2nd year,iam want know about group1 and group2 details, and we can studying without going to any instutions? please help me.

1531


What is object and example?

596


Why is abstraction used?

597


Is data hiding and abstraction same?

561


What is the full form of oops?

601


What is abstract class in oop?

524


Can you inherit a private class?

628


What does it mean when someone says I oop?

572


Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.

685