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
How do you write a function that can reverse a linked-list?
Which operator cannot overload?
What is atoi in c++?
There are 100 students in a class. The management keep information in two tables. Those two tables are given like Roll no Name Age 001 ABC 15 002 XYZ 14 and Roll No Subject Marks 001 Math 75 001 Physics 55 002 Math 68 001 Hindi 69 They want the information like this Roll No Name Hindi Physics Math Total 001 ABC 69 55 75 199 002 XYZ 68 74 84 226 And Roll No Suject Highest 001 Math 98 007 Physics 84 021 Hindi 74 All 275 All information is kept in structure in main memory. You have to find last two tables.
Can you pass a vector to a function?
How can you quickly find the number of elements stored in a dynamic array? Why is it difficult to store linked list in an array?
What are the advantages of using const reference arguments in a function?
What do you mean by friend class & friend function in c++?
What is the use of "new" operator?
What does extern mean in a function declaration in c++?
What is a stack? How it can be implemented?
What are the effects after calling the delete this operator ?
What is a down cast?
What are the advantages of using a pointer? Define the operators that can be used with a pointer.
Write a program to concatenate two strings.