Page 173 - DCAP404 _Object Oriented Programming
P. 173

Object-oriented Programming




                    Notes            network is a piconet,  and  it can consist  of one  master device  and up  to seven  slave
                                     devices.”
                                     The book guides you  to write  a MIDlet  to create “a simple Bluetooth dating service”,
                                     something to help break the ice when there are people in the same room who are attracted
                                     to each other.

                                     This is how: “You tell the MIDlet the type of date you’re looking for, and the MIDlet will
                                     use  Bluetooth  to  query  anybody  who  comes  near  yours  for  compatibility.  Once
                                     compatibility is established, your potential date’s e-mail address is displayed on your
                                     phone.”
                                     What happens thereafter  is beyond the scope  of the  book. However, be prepared for
                                     failing gracefully,  when tuning  performance. For, “given the paucity of memory in  a
                                     typical MIDP device, your application should be prepared for disappointment each time it
                                     asks for memory.”
                                     And there’s a tip as a  ‘possible strategy in production  programming’ -  that you  may
                                     “attempt to allocate all memory up front, when the application first starts”.

                                   8.5 Summary

                                      A type conversion may either be explicit or implicit, depending on whether it is ordered
                                       by the programmer or by the compiler. Explicit type conversions (casts) are used when a
                                       programmer want to get around the compiler’s typing system; for success in this endeavour,
                                       the programmer must use them correctly.

                                      Used another constructor to build a string type object from a char* type variable.
                                      The general form of an overloaded casting operator function, also referred to as a conversion
                                       function, is:

                                          operator  typename()
                                       {
                                          //Program  statement
                                       }
                                      Which  form to use, depends  upon where we want the type-conversion function to  be
                                       located, whether in the source class or in the destination class.

                                   8.6 Keywords

                                   Implicit Conversion:  An implicit conversion sequence is the sequence of conversions required
                                   to convert an argument in a  function call  to the type of the corresponding  parameter in a
                                   function declaration.
                                   Operator Typename(): Converts the class object of which it is a member to typename.

                                   8.7 Review Questions

                                   1.  “In a mixed expression constants and variables are of different data types.” Justify this
                                       statement with an example.
                                   2.  The constructor functions do not support conversion from a class to basic type. Explain
                                       with a example.




          166                               LOVELY PROFESSIONAL UNIVERSITY
   168   169   170   171   172   173   174   175   176   177   178