Differentiate between declaration and definition in C++?



Differentiate between declaration and definition in C++?..

Answer / atul shankhwar

A declaration introduces a name into the program; a definition provides a unique description of an entity (e.g. type, instance, and function). Declarations can be repeated in a given scope, it introduces a name in a given scope. There must be exactly one definition of every object, function or class used in a C++ program.

A declaration is a definition unless:

 it declares a function without specifying its body,
 it contains an extern specifier and no initializer or function body,
 it is the declaration of a static class data member without a class definition,
 it is a class name definition,
 it is a typedef declaration.
A definition is a declaration unless:
 it defines a static class data member,
 it defines a non-inline member function.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

Explain the difference between 'operator new' and the 'new' operator?

1 Answers   Lucent, TCS,


How to construct muliton object

2 Answers   Symphony, TCS,


What is the use of volatile keyword in c++? Give an example.

1 Answers  


Why is c++ considered difficult?

0 Answers  


Write about the role of c++ in the tradeoff of safety vs. Usability?

0 Answers  






Specify some guidelines that should be followed while overloading operators?

0 Answers  


Describe protected access specifiers?

0 Answers  


What is a namespace in c++?

0 Answers  


plz send me National informatics center paper pattern

1 Answers  


What is abstraction c++?

0 Answers  


what are Operators and explain with an example?

0 Answers  


How can virtual functions in c++ be implemented?

0 Answers  


Categories