What is the difference between declaration and definition?

Answer Posted / krishna chowdary garapati

Declaration means it exits but it has no meaning. But where
as definition means it has a meaning. Without decalration
there is no definition. Why means without existing how can
we use.
Some situations we do both in a single statement like,
int i = 10;
here i is declared and definie with the value 10;
But some languages give some value to the variable without
defining like
class DiffsDemo {
int i;
}

DiffsDemo demo = new DiffsDemo();
print: demo.i;
output: 0;

This will happen because some default values are assigned
to that types. Internally at run time they will define.

Is This Answer Correct ?    10 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

design a c++ class for the chess board,provide a c++ class definition for such class(only class definition is required)

6245


Which type does string inherit from?

713


What is the main purpose of inheritance law?

766


What is destructor example?

687


What is the oops and benefits of oops programming?

636






What are functions in oop?

688


What is the importance of oop?

698


What is multilevel inheritance in oop?

643


Are polymorphisms mutations?

798


Where is pseudocode used?

645


What is class and example?

671


Whats oop mean?

682


Where You Can Use Interface in your Project

1506


What is class in oop with example?

705


Why do we use inheritance?

716