Welcome to The Guardian Wars Series...In forum form
 
HomeHome  CalendarCalendar  FAQFAQ  SearchSearch  MemberlistMemberlist  UsergroupsUsergroups  RegisterRegister  Log inLog in  

Share | 
 

 Static polymorphism

View previous topic View next topic Go down 
AuthorMessage
meodingu

avatar

Posts : 201
Join date : 2010-09-30

PostSubject: Static polymorphism   Tue 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
View user profile
 
Static polymorphism
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Drew Baye On Isometric Training

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