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 is the difference between map and hashmap in c++?
Why Pointers are not used in C++?
What is the use of turbo c++?
What does std mean in c++?
What is main function in c++ with example?
What are the syntactic rules to be avoid ambiguity in multiple inheritance?
What are the benefits of operator overloading?
Assume an array of structure is in order by studentID field of the record, where student IDs go from 101 to 500. Write the most efficient pseudocode algorithm you can to find the record with a specific studentID if every single student ID from 101 to 500 is used and the array has 400 elements. Write the most efficient pseudocode algorithm you can to find a record with a studentID near the end of the IDs, say in the range from 450 to 500, if not every single student ID in the range of 101 to 500 is used and the array size is only 300
Can a program run without main in c++?
Why do we learn c++?
Which one is a preferred language C or C++? Why?
How would you use the functions randomize() and random()?
Write about the use of the virtual destructor?
Why c++ is better than c language?
What is a type library?