Tuesday, September 9, 2008

Apple Certification Exam 9L0-509

Member functions or variables declared static are shared between all instances of an object type. This 9L0-509 means that only one copy of the member function or variable exists for any object type. Named constructors are a good example of using static member functions. Named constructors is the name given to functions used to create an object of a class C without (directly) using its constructors. This might be used for the following:

1. To circumvent 9L0-402 dumps the restriction that constructors can be overloaded only if their signatures differ.
2. Making the 9L0-509 class non-inheritable by making the constructors private.
3. Preventing stack allocation by making constructors private

Declare a static member function that uses a private constructor to create the object and return it. (It could also return a pointer or a reference but this complication seems useless, and turns this into the rather than a conventional named constructor.) Here's an example 9L0-402 for a class that stores a temperature that can be specified in any of the different temperature scales.

No comments: