Page 27 - DCAP404 _Object Oriented Programming
P. 27

Object-oriented Programming




                    Notes
                                                               Table  2.1: C++ Keywords
                                    asm                double             new                switch
                                    auto               else               operator           template
                                    break              enum               private            this
                                    case               extern             protected          throw
                                    catch              float              public             try
                                    char               for                register           typedet
                                    class              friend             return             union
                                    const              goto               short              unsigned
                                    continue           if                 signed             virtual
                                    default            inline             sizeof             void
                                    delete             int                static             volatile
                                    do                 long               struct             while

                                   2.1.2  Identifiers

                                   Identifiers  refer to  the names  of variables,  functions, arrays, classes,  etc.,  created by  the
                                   programmer. They are the fundamental requirement of any language. Each language has its
                                   own rules for naming these identifiers. The following rules are common to both C and C++:
                                   1.  Only alphabetic characters, digits and underscores are permitted.
                                   2.  The name cannot start with a digit.

                                   3.  Uppercase and lowercase letters are distinct.
                                   4.  A declared keyword cannot be used as a variable name.
                                   A major difference between C and C++ is the limit on the length of a name. While ANSI C
                                   recognizes only the first 32 characters in a name, C++ places no limit on its length and, therefore,
                                   all  the characters in a name are significant.
                                   Care should be exercised while naming a variable that is being shared by more than one file
                                   containing C and C++ programs. Some operating systems impose a restriction on the length of
                                   such a variable name.


                                       !
                                     Caution  The first character in an identifier must be a letter or the _ (underscore) character;
                                     however, beginning identifiers with an  underscore is considered poor  programming
                                     style.

                                   Self Assessment

                                   Fill in the blanks:
                                   1.  The keywords not found in ANSI C are shown …………………. .

                                   2.  A major difference between C and C++ is the limit on the length of a………………. .






          20                                LOVELY PROFESSIONAL UNIVERSITY
   22   23   24   25   26   27   28   29   30   31   32