[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppDeclaration

(C++) Function declaration

Specifying which arguments a function takes and what it returns. What the function preforms internally is specified in the definition.

You do not need to include the argument names in the declaration, just their types. It is common to put function declarations in header files with extension .h and .hpp, whereas their definition is put in .cpp files.

double calculateSum(const std::vector<double>&);


The only function that cannot be declared is main()

Comparision to C

//C++ function taking no arguments 
void myFunction();


/* C function taking no arguments */
void myFunction(void);


Comparison to Prolog

A C++ declaratation is like a Prolog predicate

//Function declarations in C++
void myFunction1()
void myFunction2(const std::string&);
void myFunction3(const std::string&, std::string&); 


% Predicates in Prolog
predicates
  myFunction1()
  myFunction2(string)- (i)          % 'i' denotes input
  myFunction3(string,string)- (i,o) % 'o' denotes output




'Declaration' links



last edited (December 8, 2006) by bilderbikkel, Number of views: 4890, Current Rev: 12 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.