Differentiate between declaration and definition in C++?
Answer Posted / 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 View All Answers
What data structure is fastest, on average, for retrieving data: a) Binary Tree b) Hash Table c) Stack
If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?
Why c++ is better than c language?
What is lambda expression c++?
Is there a sort function in c++?
Why is c++ still best?
Describe linked list using C++ with an example.
How java is different from c and c++?
How should runtime errors be handled in c++?
What is polymorphism & list its types in c++?
What is the best it certification?
How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?
Why do we need function?
Comment on local and global scope of a variable.
What is polymorphism and its type in c++?