The Guardian Wars
Would you like to react to this message? Create an account in a few clicks or log in to continue.


Welcome to The Guardian Wars Series...In forum form
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

 

 Static polymorphism

Go down 
AuthorMessage
meodingu

meodingu


Posts : 201
Join date : 2010-09-30

Static polymorphism Empty
PostSubject: Static polymorphism   Static polymorphism I_icon_minitimeTue 11 Jan 2011, 2:24 pm

Static polymorphism

Function overloading allows programs to declare multiple functions having the same name (but with different arguments). The functions are distinguished by the number and/or types of their formal parameters. Thus, the same function name can refer to different functions depending on the context in which it is used. The type returned by the function is not used to distinguish overloaded functions.

When declaring a function, a programmer can specify default value for one or more parameters. Doing so allows the parameters with defaults to optionally be omitted when the function is called, in which case the default arguments will be used. When a function is called with fewer arguments than there are declared parameters, explicit arguments are matched to parameters in left-to-right order, with any unmatched parameters at the end of the parameter list being assigned their default arguments. In many cases, specifying default arguments in a single function declaration is preferable to providing overloaded function definitions with different numbers of parameters.

Templates in C++ provide a sophisticated mechanism for writing generic, polymorphic code. In particular, through the Curiously Recurring Template Pattern it's possible to implement a form of static polymorphism that closely mimics the syntax for overriding virtual functions. Since C++ templates are type-aware and Turing-complete they can also be used to let the compiler resolve recursive conditionals and generate substantial programs through template metaprogramming.


best small towns to live in
Rush Concert Tickets
Back to top Go down
 
Static polymorphism
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
The Guardian Wars :: Soul Realm :: Moonshine Town-
Jump to: