Function

From Chilipedia
Revision as of 12:59, 1 August 2016 by Chili (Talk | contribs) (Created page with "A function is a grouping of code that you can invoke or 'call' from one or more points in your program. You can even call a function from itself (motherfucking funception)! =...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A function is a grouping of code that you can invoke or 'call' from one or more points in your program. You can even call a function from itself (motherfucking funception)!

Function Calls

A function call in C++ generally looks something like this obj.MyFunction( param1,param2 ). It consists of the function name (Myfunction in the example above) followed parentheses () which surround parameters separated by commas (,). To call a member function of an object, you first type the object name, then a period '.', and then the function name (e.g. obj.).

The function parameters are used to control the behavior of the function. A function can have zero or more of these. A function can also return a value, which can be used in other operations. If a function does not return a value, its return type is void.