C++ INTRODUCTION AND TOKENSMade by:                                             RAFIYA SIRIN                                                    XI-B
C++ INTRODUCTIONC++ was developed by Bjarne Stroustrup of AT&T Bell Laboratories in the early 1980's, and is based on the C language. The name is a pun - "++" is a syntactic construct used in C  and C++ is intended as an incremental improvement of C. Most of C is  subset of C++, so that most C programs can be compiled (i.e. converted into a series of low-level instructions that the computer can execute directly) using a C++ compiler.The name C++ was coined by Rick Mascitti. Ever since it’s birth it has coped up with problems encountered by users, and through discussions at AT&T. however the maturation of the C++ language is attested to by two recent events:(i) the formation of American National Standard Institute) C++ committee (ii) the publication of The Annotated C++ Reference Manual by Ellis and Stroustrup.
Because C++ retains C as a subset, it gains many of the attractive features of the C language, such as efficiency, closeness to the machine, and a variety of built-in types. A number of new features were added to C++ to make the language even more robust, many of which are not used by novice programmers. By introducing these new features here, we hope that you will begin to use them in your own programs early on and gain their benefits. Some of the features we will look at are the role of constants, inline expansion, references, declaration statements, user defined types, overloading, and the free store.
THE SMALLEST INDIVIDUAL UNIT IN A PROGRAM IS KNOWN AS A TOKEN OR A LEXICAL UNITTOKENS
KEYWORDSIDENTIFIERSTOKENSLITERALSPUNCTUATORSOPERATORS
KEYWORDSIn computer programming, a keyword is a word or identifier that has a particular meaning to the programming language. The meaning of keywords — and, indeed, the meaning of the notion of keyword — differs widely from language to language. In many languages, such as C and similar environments like C++, a keyword is a reserved word which identifies a syntactic form. Words used in control flow constructs, such as if, then, and else are keywords. In these languages, keywords can also be used as the names of variables or functions.
C++ KEYWORDS
IDENTIFIERSIn computer science, Identifiers (IDs) are lexical tokens that name entities. The concept is analogous to that of a "name." Identifiers are used extensively in virtually all information processing systems. Naming entities makes it possible to refer to them, which is essential for any kind of symbolic processing.Computer languages usually place restrictions on what characters may appear in an identifier. For example, in early versions the C and C++ language, identifiers are restricted to being a sequence of one or more ASCII letters, digits (these may not appear as the first character), and underscores. Later versions of these languages, along with many other modern languages support almost all Unicode characters in an identifier (a common restriction is not to permit white space characters and language operators).
RULES FOR DETERMING AN IDENTIFIERFirst character must be a letterAfter that any combination of letters and digits can be taken.Only underscore can be included and must be treated as a letter.Keywords cannot be used as identifiers.
SOME VALID AND INVALID IDENTIFIERSVALID:- My file      DATE9_7_77      Z2T0Z9                MYFILE       _DS                 _HJI3_JK                _CHK            FILE13INVALID:- DATA-REC    contains special character                      29CLCT         starting with a digit                      break           reserved keyword                       My.file        contains special character
LITERALSIn computer science, a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as integers, floating-point numbers, strings, and Booleans; some also have notations for elements of enumerated types and compound values such as arrays, records, and objects. Literals are divided into four types:integer-constant character- constantFloating constantString-literal
INTEGER CONSTANTSThey are whole numbers without any fractional parts. the method of writing integer constants has been specified in following rule:- an integer constant must have at least one digit and must not contain any decimal point. It may contain either + or – sign. A number with no sign is assumed to be positive. Commas cannot appear in an integer constant. This again has three types: (i)decimal(base 10)(ii)octal(base 8)(iii)hexadecimal(base 16)
CHARACTER CONSTANTA character constant is one character enclosed in single quotes, as in ‘z’. The rule for writing character constant is given below:-      a character constant is C++must contain one character and must be enclosed in single quotation marks.C++ allows us to have certain non-graphic characters. These cannot be typed directly from keyboard. E.g., backspace, tabs, carriage, return etc.
ESCAPE SEQUENCE
FLOATING CONSTANTSFloating constants are also called real constants.Real constants are functions having fractional parts. These may be written in one of the two forms called fractional form or the exponent form. It consists of signed or unsigned digits including a decimal point between digits. The rule for writing a real constant is:-A real constant in fractional form must have at least one digit after the decimal point. It may also have either + or – sign preceding it. A real constant with no sign is assumed to be positive.
STRING LITERALS:-Multiple character constants are treated as string- literals. The rule for writing string-literal is given below:-A string literal is a sequence of characters surrounded by double quotes.Specifically, most string literals can be specified using: declarative notation; whitespace delimiters (indentation); bracketed delimiters (quoting); escape characters; or a combination of some or all of the above
PUNCTUATORSA punctuator is a token that has syntactic and semantic meaning to the compiler, but the exact significance depends on the context. A punctuator can also be a token that is used in the syntax of the preprocessor.
OPERATORSOperators are tokens that trigger some computation when applied to variables and other objects in an expression. The following list gives a brief description of the operators and their functions.Unary operators require one operand to operate upon.Binary operators require two operands to operate upon.
ORDER OF PRECEDENCE( )  [ ]  ! ~ + - ++ -- & *(typeset)* / %+ - << >>< <=  !=&^ I&&II?:=  *= / %=   += -=  &=  ^=  I=  <  <=  >  >=
THANK YOU

C++

  • 1.
    C++ INTRODUCTION ANDTOKENSMade by: RAFIYA SIRIN XI-B
  • 2.
    C++ INTRODUCTIONC++ wasdeveloped by Bjarne Stroustrup of AT&T Bell Laboratories in the early 1980's, and is based on the C language. The name is a pun - "++" is a syntactic construct used in C and C++ is intended as an incremental improvement of C. Most of C is subset of C++, so that most C programs can be compiled (i.e. converted into a series of low-level instructions that the computer can execute directly) using a C++ compiler.The name C++ was coined by Rick Mascitti. Ever since it’s birth it has coped up with problems encountered by users, and through discussions at AT&T. however the maturation of the C++ language is attested to by two recent events:(i) the formation of American National Standard Institute) C++ committee (ii) the publication of The Annotated C++ Reference Manual by Ellis and Stroustrup.
  • 3.
    Because C++ retainsC as a subset, it gains many of the attractive features of the C language, such as efficiency, closeness to the machine, and a variety of built-in types. A number of new features were added to C++ to make the language even more robust, many of which are not used by novice programmers. By introducing these new features here, we hope that you will begin to use them in your own programs early on and gain their benefits. Some of the features we will look at are the role of constants, inline expansion, references, declaration statements, user defined types, overloading, and the free store.
  • 4.
    THE SMALLEST INDIVIDUALUNIT IN A PROGRAM IS KNOWN AS A TOKEN OR A LEXICAL UNITTOKENS
  • 5.
  • 6.
    KEYWORDSIn computer programming,a keyword is a word or identifier that has a particular meaning to the programming language. The meaning of keywords — and, indeed, the meaning of the notion of keyword — differs widely from language to language. In many languages, such as C and similar environments like C++, a keyword is a reserved word which identifies a syntactic form. Words used in control flow constructs, such as if, then, and else are keywords. In these languages, keywords can also be used as the names of variables or functions.
  • 7.
  • 8.
    IDENTIFIERSIn computer science,Identifiers (IDs) are lexical tokens that name entities. The concept is analogous to that of a "name." Identifiers are used extensively in virtually all information processing systems. Naming entities makes it possible to refer to them, which is essential for any kind of symbolic processing.Computer languages usually place restrictions on what characters may appear in an identifier. For example, in early versions the C and C++ language, identifiers are restricted to being a sequence of one or more ASCII letters, digits (these may not appear as the first character), and underscores. Later versions of these languages, along with many other modern languages support almost all Unicode characters in an identifier (a common restriction is not to permit white space characters and language operators).
  • 9.
    RULES FOR DETERMINGAN IDENTIFIERFirst character must be a letterAfter that any combination of letters and digits can be taken.Only underscore can be included and must be treated as a letter.Keywords cannot be used as identifiers.
  • 10.
    SOME VALID ANDINVALID IDENTIFIERSVALID:- My file DATE9_7_77 Z2T0Z9 MYFILE _DS _HJI3_JK _CHK FILE13INVALID:- DATA-REC contains special character 29CLCT starting with a digit break reserved keyword My.file contains special character
  • 11.
    LITERALSIn computer science,a literal is a notation for representing a fixed value in source code. Almost all programming languages have notations for atomic values such as integers, floating-point numbers, strings, and Booleans; some also have notations for elements of enumerated types and compound values such as arrays, records, and objects. Literals are divided into four types:integer-constant character- constantFloating constantString-literal
  • 12.
    INTEGER CONSTANTSThey arewhole numbers without any fractional parts. the method of writing integer constants has been specified in following rule:- an integer constant must have at least one digit and must not contain any decimal point. It may contain either + or – sign. A number with no sign is assumed to be positive. Commas cannot appear in an integer constant. This again has three types: (i)decimal(base 10)(ii)octal(base 8)(iii)hexadecimal(base 16)
  • 13.
    CHARACTER CONSTANTA characterconstant is one character enclosed in single quotes, as in ‘z’. The rule for writing character constant is given below:- a character constant is C++must contain one character and must be enclosed in single quotation marks.C++ allows us to have certain non-graphic characters. These cannot be typed directly from keyboard. E.g., backspace, tabs, carriage, return etc.
  • 14.
  • 15.
    FLOATING CONSTANTSFloating constantsare also called real constants.Real constants are functions having fractional parts. These may be written in one of the two forms called fractional form or the exponent form. It consists of signed or unsigned digits including a decimal point between digits. The rule for writing a real constant is:-A real constant in fractional form must have at least one digit after the decimal point. It may also have either + or – sign preceding it. A real constant with no sign is assumed to be positive.
  • 16.
    STRING LITERALS:-Multiple characterconstants are treated as string- literals. The rule for writing string-literal is given below:-A string literal is a sequence of characters surrounded by double quotes.Specifically, most string literals can be specified using: declarative notation; whitespace delimiters (indentation); bracketed delimiters (quoting); escape characters; or a combination of some or all of the above
  • 17.
    PUNCTUATORSA punctuator isa token that has syntactic and semantic meaning to the compiler, but the exact significance depends on the context. A punctuator can also be a token that is used in the syntax of the preprocessor.
  • 19.
    OPERATORSOperators are tokensthat trigger some computation when applied to variables and other objects in an expression. The following list gives a brief description of the operators and their functions.Unary operators require one operand to operate upon.Binary operators require two operands to operate upon.
  • 21.
    ORDER OF PRECEDENCE() [ ] ! ~ + - ++ -- & *(typeset)* / %+ - << >>< <= !=&^ I&&II?:= *= / %= += -= &= ^= I= < <= > >=
  • 22.