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


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.

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
This programming assignment is for use in the LINUX/UNIX environment!! Introduction: System administration often requires custom written programs and tools. One problem a s

limitation of function

In order to override a method, a subclass of the class which originally declared the method have to declare a method along with the same name, return type (or a subclass of that re

C o n t r o l S t r u c t u r e s I t i s o f t h r e e t y p e s: 1 .    S e qu e n c e s t r u c t u r e 2 .

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

What are compound statements? - Compound statements are made up of two or more program statements that are executed together. They may be executed with a loop. - Curly brack

How do you declare an integer variable? Explain with an example.

In this worksheet you are asked to write three classes in C++: Lecture class, Course class and University class. The classes relate to each other in the way that a Course has many

Write a program to print a digital clock which displays the time for 2 hours .

a c program to find the volume of sphere