What is a Function in C++?

By




 0 | 1 | 2  Keyword    function is c++    function is inaccessible c++    function is prime c++    function is protected c++    virtual function is c++    function c++ definition    function c++11    function c++ pdf    function c++ return array    function c++ ppt a     function c++ array    function c++ average    function c++ arguments    function alias c++    function address c++    function abs c++    function atoi c++    function append c++    function pointer c++ as argument    function access c++ b     function c++ by reference    function c++ boost    function body c++    function bool c++    function bind c++    function beep c++    function borland c++    function parameter c++ by reference    function block c++    function break c++ c     function c++ const    function c++ char    function c++ class    __function__ c++ class name    function c++ cout    function c++ const parameter    function callback c++    function pointer c++ class    function pointer c++ class method    function pointer c++ class member d     function is deprecated c++    function c++ declaration    function c++ default argument    function c++ default value    function c++ double    function c++ default parameter    function c++ documentation    function dev c++    function definition c++ example e     function c++ example    function c++ exercise    function overloading c++ example    function prototype c++ example    function pointer c++ example    function overloading c++ example program    function template c++ example    function object c++ example    function exit c++ f     function c++ factorial    function for c++    function friend c++    function find c++    function fibonacci c++    function floor c++    function float c++    function free c++    function fabs c++    function in c++ for string g     __function__ c++ gcc    function getline c++    function get c++    function gcd c++    function gotoxy c++    function goto c++    function gamma c++    function getch c++    function generator c++    function global c++ h     function c++ header    function c++ .h    function hiding c++    function handle c++    function hooking c++    function header c++ definition    function hypotenuse c++    function handler c++    function hash c++    function declaration c++ header file i     function c++ identifier not found    function c++ inline    function in c++    function in c++ pdf    function in c++ ppt    function in c++ definition    function inheritance c++    function in c++ exercises    function if c++ k     function keyword c++    function keys c++    function kill c++    function kbhit c++ l     function c++ lecture notes    __function__ c++ linux    function in c++ language    function library c++    function length c++    function list c++    function lambda c++    function loop c++    function log c++    function sleep c++ linux m     function c++ meaning    function c++ max    function c++ macro    function c++ multiple output    function min c++    function main c++    function map c++    function member c++    function minimization c++    function matrix c++ n     function c++ notes    function name c++    function new c++    function name c++ macro    function namespace c++    function pointer c++ null    function notation c++    function n c++    function nesting c++    c++ function is not marked const o     function c++ overloading    function object c++    function overriding c++    function of c++    function of c++ pdf    function overloading c++ area program    function overloading c++ ppt    function overloading c++ different return types p     is_function_pointer c++    function c++ programming    function c++ pass by reference    function c++ prototype    function c++ pointer argument    function c++ parameter q     function c++ questions    function c++ quiz    function qualifier c++    function queue c++    function pointer c++ qt r     function c++ return    function c++ return 2 values    function c++ reference    function c++ return string    function c++ return vector    function c++ return pointer    function c++ return reference    function c++ return char    function c++ reverse string s     function c++ syntax    function c++ string    function c++ std    function c++ static    function c++ string parameter    function c++ size of array    function signature c++    function sort c++    function specialization c++    function scope c++ t     function c++ tutorial    function c++ template    function c++ template argument    function pointer c++ typedef    function recursion c++ tutorial    function time c++    function throw c++    function table c++    function traits c++    function object c++ tutorial u     function is undefined c++    __function__ c++ unicode    operator function is unavailable c++    function using c++    function unique c++    function undeclared c++    function uppercase c++    function update c++    function unlink c++    function usleep c++ v     function c++ void    function c++ visual studio    function c++ vector    function c++ variable arguments    function c++ variable pointer    function variable c++    function visual c++    function virtual c++    function in c++ video    function pointer c++ vector w     function c++ wikipedia    function c++ with examples    function wrapper c++    function while c++    function overloading c++ with example    function wait c++    function pointer c++ with arguments    function overloading c++ wiki x     function x c++ y     function c++ youtube    function overloading c++ youtube 0     function 0 c++ 1     function c++ 11    function template c++ 11    function 1 c++    function object c++ 11 2     function prototype c++ 2d array Get more keywords ideas  Use Übersuggest to quickly find new keywords not available in the Google Keyword Planner. Take your keyword research to the next level with tons of keyword ideas for SEO, PPC and your next content marketing campaign.  Need more data?  Install the free KeywordEverywhere extension for Chrome and Firefox and you'll get search volume and CPC for free.      Basic usage  A short video (less than 60 seconds) about how to use the basic features of Übersuggest for your keyword research     About Privacy Facebook Twitter × Copy & Paste Your Keywords  function is c++ function is inaccessible c++ function is prime c++ function is protected c++ virtual function is c++ function c++ definition function c++11 function c++ pdf function c++ return array function c++ ppt function c++ array function c++ average function c++ arguments function alias c++ function address c++ function abs c++ function atoi c++ function append c++ function pointer c++ as argument function access c++ function c++ by reference function c++ boost function body c++ function bool c++ function bind c++ function beep c++ function borland c++ function parameter c++ by reference function block c++ function break c++ function c++ const function c++ char function c++ class __function__ c++ class name function c++ cout function c++ const parameter function callback c++ function pointer c++ class function pointer c++ class method function pointer c++ class member function is deprecated c++ function c++ declaration function c++ default argument function c++ default value function c++ double function c++ default parameter function c++ documentation function dev c++ function definition c++ example function c++ example function c++ exercise function overloading c++ example function prototype c++ example function pointer c++ example function overloading c++ example program function template c++ example function object c++ example function exit c++ function c++ factorial function for c++ function friend c++ function find c++ function fibonacci c++ function floor c++ function float c++ function free c++ function fabs c++ function in c++ for string __function__ c++ gcc function getline c++ function get c++ function gcd c++ function gotoxy c++ function goto c++ function gamma c++ function getch c++ function generator c++ function global c++ function c++ header function c++ .h function hiding c++ function handle c++ function hooking c++ function header c++ definition function hypotenuse c++ function handler c++ function hash c++ function declaration c++ header file function c++ identifier not found function c++ inline function in c++ function in c++ pdf function in c++ ppt function in c++ definition function inheritance c++ function in c++ exercises function if c++ function keyword c++ function keys c++ function kill c++ function kbhit c++ function c++ lecture notes __function__ c++ linux function in c++ language function library c++ function length c++ function list c++ function lambda c++ function loop c++ function log c++ function sleep c++ linux function c++ meaning function c++ max function c++ macro function c++ multiple output function min c++ function main c++ function map c++ function member c++ function minimization c++ function matrix c++ function c++ notes function name c++ function new c++ function name c++ macro function namespace c++ function pointer c++ null function notation c++ function n c++ function nesting c++ c++ function is not marked const function c++ overloading function object c++ function overriding c++ function of c++ function of c++ pdf function overloading c++ area program function overloading c++ ppt function overloading c++ different return types is_function_pointer c++ function c++ programming function c++ pass by reference function c++ prototype function c++ pointer argument function c++ parameter function c++ questions function c++ quiz function qualifier c++ function queue c++ function pointer c++ qt function c++ return function c++ return 2 values function c++ reference function c++ return string function c++ return vector function c++ return pointer function c++ return reference function c++ return char function c++ reverse string function c++ syntax function c++ string function c++ std function c++ static function c++ string parameter function c++ size of array function signature c++ function sort c++ function specialization c++ function scope c++ function c++ tutorial function c++ template function c++ template argument function pointer c++ typedef function recursion c++ tutorial function time c++ function throw c++ function table c++ function traits c++ function object c++ tutorial function is undefined c++ __function__ c++ unicode operator function is unavailable c++ function using c++ function unique c++ function undeclared c++ function uppercase c++ function update c++ function unlink c++ function usleep c++ function c++ void function c++ visual studio function c++ vector function c++ variable arguments function c++ variable pointer function variable c++ function visual c++ function virtual c++ function in c++ video function pointer c++ vector function c++ wikipedia function c++ with examples function wrapper c++ function while c++ function overloading c++ with example function wait c++ function pointer c++ with arguments function overloading c++ wiki function x c++ function c++ youtube function overloading c++ youtube function 0 c++ function c++ 11 function template c++ 11 function 1 c++ function object c++ 11 function prototype c++ 2d array   Close


Think of an ATM. You enter your pin code and the amount you want to withdraw. The output is the cash and the receipt. A lot of things happen inside the ATM as well, but we do not know about them.
Same is a Function in C++ or any other programming language. A Function takes (not always) some values as inputs, uses them for processing and then provides the result.
Connecting the analogies, the pin code and amount are the inputs. Bank deducts that amount from your bank account(processing) and then the output is the cash and receipt in your hand.
Similarly, we can say that facebook.com is also a function. You visit facebook.com, input your email id and password, some processing happens at the servers and the output you get is access to your own personal account.


Most Functions in C++ take inputs and provide outputs but that is not mandatory. A Function may or may not take inputs. Which means that there could be functions that only perform some task without taking inputs every time they are executed.
Take an example of a table lamp. It does not accept any input when you switch it on(a fan does take input in form of fan speed controlled by the regulator) but provides you with output in form of light with help of some of its internal processes.


What are different attributes of a Function in C++?

1. Function Return Type
It is the data type of the value that the function will return as a result of its execution. If you develop a function that adds two integer numbers and returns their sum, the return type for the function would be ‘int’.
In many cases, a function will not return any value. In such cases, the return type is ‘void’.
A return type of a function comes into play at the time of calling the function, where the result returned by the function is to be stored into a variable. The data types of the - (a) return type of the function and (b) the variable in which the returned value is to be stored - have to be the same.
Example:
int AddTwoNumbers(int a, int b) // Function declaration & definition
{
int c; // Processing, step 1
c=a+b; // Processing, step 2
return c; // Returning the result
}

2. Function Name
It is the name given to a particular function. Names of two or more functions can be same in a program (Function Overloading and Function Overriding), but we suggest you, as a
beginner, to stick with unique function names before you get a good grip over the use of Function Overloading and Function Overriding.

3. Function Arguments/Parameters
These are the values that are passed into the function when it is used. These values are the inputs to the processing that takes place when the function is called.
If you develop a function to add two numbers then the two numbers will have (not mandatory, alternatives exist) to be provided to the function in form of arguments.
Example:
int AddTwoNumbers(int a, int b) // Function declaration & definition
{
int c; // Processing, step 1
c=a+b; // Processing, step 2
return c; // Returning the result
}

4. Function Body
This part is the definition of the function and includes all the processing that is to be done by the function and the return (if any) of the result.
Example:
int AddTwoNumbers(int a, int b) // Function declaration & definition
{
int c; // Processing, step 1
c=a+b; // Processing, step 2
return c; // Returning the result
}


  1. function is c++
  2. function is inaccessible c++
  3. function is prime c++
  4. function is protected c++
  5. virtual function is c++
  6. function c++ definition
  7. function c++11
  8. function c++ pdf
  9. function c++ return array
  10. function c++ ppt
  11. function c++ array
  12. function c++ average
  13. function c++ arguments
  14. function alias c++
  15. function address c++
  16. function abs c++
  17. function atoi c++
  18. function append c++
  19. function pointer c++ as argument
  20. function access c++
  21. function c++ by reference
  22. function c++ boost
  23. function body c++
  24. function bool c++
  25. function bind c++
  26. function beep c++
  27. function borland c++
  28. function parameter c++ by reference
  29. function block c++
  30. function break c++
  31. function c++ const
  32. function c++ char
  33. function c++ class
  34. __function__ c++ class name
  35. function c++ cout
  36. function c++ const parameter
  37. function callback c++
  38. function pointer c++ class
  39. function pointer c++ class method
  40. function pointer c++ class member
  41. function is deprecated c++
  42. function c++ declaration
  43. function c++ default argument
  44. function c++ default value
  45. function c++ double
  46. function c++ default parameter

  47. function find c++
  48. function fibonacci c++
  49. function floor c++
  50. function float c++
  51. function free c++
  52. function fabs c++
  53. function in c++ for string
  54. __function__ c++ gcc
  55. function getline c++
  56. function get c++
  57. function gcd c++
  58. function gotoxy c++
  59. function goto c++
  60. function gamma c++
  61. function getch c++
  62. function generator c++
  63. function global c++
  64. function c++ header
  65. function c++ .h
  66. function hiding c++
  67. function handle c++
  68. function hooking c++
  69. function header c++ definition
  70. function hypotenuse c++
  71. function handler c++
  72. function hash c++
  73. function declaration c++ header file
  74. function c++ identifier not found
  75. function c++ inline
  76. function in c++
  77. function in c++ pdf
  78. function in c++ ppt
  79. function in c++ definition
  80. function inheritance c++
  81. function in c++ exercises
  82. function if c++
  83. function keyword c++
  84. function keys c++
  85. function kill c++
  86. function kbhit c++
  87. function c++ lecture notes
  88. __function__ c++ linux
  89. function in c++ language
  90. function library c++
  91. function length c++
  92. function list c++
  93. function lambda c++
  94. function loop c++
  95. function log c++
  96. function sleep c++ linux
  97. function c++ meaning
  98. function c++ max
  99. function c++ macro
  100. function c++ multiple output
  101. function min c++
  102. function main c++
  103. function map c++
  104. function member c++
  105. function minimization c++
  106. function matrix c++
  107. function c++ notes
  108. function name c++
  109. function new c++
  110. function name c++ macro
  111. function namespace c++
  112. function pointer c++ null
  113. function notation c++
  114. function n c++
  115. function nesting c++
  116. c++ function is not marked const
  117. function c++ overloading
  118. function object c++
  119. function overriding c++
  120. function of c++
  121. function of c++ pdf
  122. function overloading c++ area program
  123. function overloading c++ ppt
  124. function overloading c++ different return types
  125. is_function_pointer c++
  126. function c++ programming
  127. function c++ pass by reference
  128. function c++ prototype
  129. function c++ pointer argument
  130. function c++ parameter
  131. function c++ questions
  132. function c++ quiz
  133. function qualifier c++
  134. function queue c++
  135. function pointer c++ qt
  136. function c++ return
  137. function c++ return 2 values
  138. function c++ reference
  139. function c++ return string
  140. function c++ return vector
  141. function c++ return pointer
  142. function c++ return reference
  143. function c++ return char
  144. function c++ reverse string
  145. function c++ std
  146. function c++ static
  147. function c++ string parameter
  148. function c++ size of array
  149. function signature c++
  150. function sort c++
  151. function specialization c++
  152. function scope c++
  153. function c++ tutorial
  154. function c++ template
  155. function c++ template argument
  156. function pointer c++ typedef
  157. function recursion c++ tutorial
  158. function time c++
  159. function throw c++
  160. function table c++
  161. function traits c++
  162. function object c++ tutorial
  163. function is undefined c++
  164. __function__ c++ unicode
  165. operator function is unavailable c++
  166. function using c++
  167. function unique c++
  168. function undeclared c++
  169. function uppercase c++
  170. function update c++
  171. function unlink c++
  172. function usleep c++
  173. function c++ void
  174. function c++ visual studio
  175. function c++ vector
  176. function c++ variable arguments
  177. function c++ variable pointer
  178. function variable c++
  179. function visual c++
  180. function virtual c++
  181. function in c++ video
  182. function pointer c++ vector
  183. function c++ wikipedia
  184. function c++ with examples
  185. function wrapper c++
  186. function while c++
  187. function overloading c++ with example
  188. function wait c++
  189. function pointer c++ with arguments
  190. function overloading c++ wiki
  191. function x c++
  192. function c++ youtube
  193. function overloading c++ youtube
  194. function 0 c++
  195. function c++ 11
  196. function template c++ 11
  197. function 1 c++
  198. function object c++ 11
  199. function prototype c++ 2d array

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete