Function declarations and function definitions in cpp, C/C++ Programming

FUNCTIONS

It refers to a subprogram that is meant to do a certain task. It is basically used to execute a set of operations and return information to the main or calling function.

 

Basic Format:

return_data_type function_name(data_type par1, data_type par2,...)
{

Statement  1;

Statement  2;

}

Function Declarations and Function Definitions

Every function in program must have a function declaration and a function definition. Function declaration refers to the functions name, return data type and parameters (function prototype) while Function definition refers to the implementation of a particular function. Function declaration and function definition appear together to form a function

 

Static type checking

It refers to the checking of the data types used in all functions are appropriate to the actual function

requirements. This ensures that any function cannot be called with wrong number of parameters or

inappropriate argument types  i.e. C++ does not allow any function to be used before it has been declared and the reason is that the compiler can perform static type checking.

 

Function prototypes

This is a function declaration statement that informs the compiler of the type of data returned by the
functions, the number of parameters the function expects and order in which they are expected.
Format:

return_type function_name  (list of parameters); 

 

Posted Date: 8/21/2012 11:48:25 AM | Location : United States







Related Discussions:- Function declarations and function definitions in cpp, Assignment Help, Ask Question on Function declarations and function definitions in cpp, Get Answer, Expert's Help, Function declarations and function definitions in cpp Discussions

Write discussion on Function declarations and function definitions in cpp
Your posts are moderated
Related Questions

Project Description: Need someone to prepare a trading platform and sophisticated trading strategy. Must have knowledge and experience in most of these: QuickFIX, Esper, Quan

Write the statements which are used to connect PHP with MySQL? Statements which can be used to connect PHP with MySQL is: $conn = mysql_connect('localhost'); echo $co

Question: (a) Write down the class 'ListNode' to contain the following:- (i) variable data of type Object (ii) variable next of type ListNode (iii)

Requirements Create a "makefile" that will manage the construction of a program The name of the makefile must be: makefile The make file must produce an executable

Aim: To implement a program to display a rectangle, circle and triangle. Code:                       class shape {             public:                         vir

HWID Spoofer for Windows 7, 8 x64 Project Description: I want a simple program that will spoof my hardware id. I should be able to prepare the id to spoof to in the program a

Build a program that calculates a discount for items based on quantity bought each item is $99.99 Ask user to enter the quantity of the items Get the quantity of items from the u


An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase. For example the anagram of tea is tea, tae, eat, eta,