Polymorphism allows one common interface for many executions and for objects to operate in another way under various circumstances.
C ++ supports some sorts of static and dynamic polymorphisms (in execution time). Collect single polymorphism, does not consider certain solutions in execution time while polymorphism in execution time is typically fined jobs.
Static polymorphism
Function overload
Function overload allows programs to declare the multiple functions having the same name (but with various arguments). Functions distinguish number and-or types of their formal parametres. Thus, the same name of function can access to various functions depending on a context in which it is used. The type returned by function, is not used to distinguish the overloaded functions.
Arguments by default
Declaring function, the programmer can define arguments by default for one or more parametres. Performance so allows parametres with non-payments any way to be omitted when function name when arguments will be used by default. When function name with smaller quantity of arguments than, there are declared by parametres, obvious arguments are picked up to parametres from left to right in the order, with any unsurpassed parametres in the end of the list of the parametre assigned by their arguments by default. In most cases definition of arguments by default in the unique declaration of function is preferable to support of the overloaded definitions of function with various numbers of parametres.
Templates of function and Class
Templates in C ++ provide the difficult mechanism of the patrimonial, polymorphic code. In particular, through Curiously coming back the Sample of the Template probably to carry out the form of static polymorphism which close imitates syntax to reject real-valued functions. Since then C ++ templates are informed on type and Turing-are complete, they can be used also to allow the compiler to solve recursive conditional sentences and to make essential programs through metaprogramming template.
eladó tűzhely - eladó split klíma - mother of the bride dresses - weddingretailer.com
|