[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppMethod » CppPrivate » The GPRMC Sentence » QBasicFAQ » QbasicFAQ_UsingSoundCard » CppVcl » QbasicFAQ_BadFileMode » database » WhatLinksHere » encryption » CppDefinition
Opposite of a declaration:
Postpone variable definitions as long as possible [1].
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppMethod » CppPrivate » The GPRMC Sentence » QBasicFAQ » QbasicFAQ_UsingSoundCard » CppVcl » QbasicFAQ_BadFileMode » database » WhatLinksHere » encryption » CppDefinition
(C++) Definition
Specifying the value of a variable or specifying the body of a function.Variable definition
Setting the value of a variable:const int value = 3;
Opposite of a declaration:
int declaredValue; //Just a declaration, can be any value
Postpone variable definitions as long as possible [1].
Function definition
Specifying the internals of a function, instead of declaring the function's arguments and return type. Function definitions are mostly found in .cpp files.
double calculateSum(const std::vector<double>& myVector)
{
double sum = 0.0;
const int size = myVector.size();
for (int i=0; i!=size; ++i)
{
sum+=myVector[i];
}
return sum;
}
'Definition' links
Code links
Reference
- 1) Scott Meyers. Effective C++ (3rd edition).ISBN: 0-321-33487-6. Item 26: 'Postpone variable definitions as long as possible'.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
