O'Reilly logo
  • Yuan Peng Chiang thinks this is interesting:

55: FunctionTwo (const SimpleCat * const theCat)
56: {
57:     std::cout << "Function Two. Returning ...\n";
58:     std::cout << "Frisky is now " << theCat->GetAge();
59:     std::cout << " years old \n";
60:     // theCat->SetAge(8); const!
61:     return theCat;
62: }


From

Cover of Sams Teach Yourself C++ in 24 Hours, fifth edition

Note

This is a function definition.

A definition can be used in the place of a declaration.

An identifier can be declared as often as you want. Thus, the following is legal in C and C++:

double f(int, double);
double f(int, double);
extern double f(int, double); // the same as the two above
extern double f(int, double);

However, it must be defined exactly once. If you forget to define something that's been declared and referenced somewhere, then the linker doesn't know what to link references to and complains about a missing symbols. If you define something more than once, then the linker doesn't know which of the definitions to link references to and complains about duplicated symb...