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



last edited (December 6, 2006) by bilderbikkel

Back to the page