1 / 13

Advanced Programming Basics

Constants, Declarations, and Definitions. Advanced Programming Basics. C++ Program Elements. C++ C. Lexical Tokens. Character Set Keywords Identifiers Constants Literal Strings Operators Punctuators Special Characters. C++ Character Set. a -- z A -- Z 0 -- 9

sian
Télécharger la présentation

Advanced Programming Basics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Constants, Declarations, and Definitions Advanced ProgrammingBasics

  2. C++ Program Elements C++ C CSCI 240: Computing II

  3. Lexical Tokens • Character Set • Keywords • Identifiers • Constants • Literal Strings • Operators • Punctuators • Special Characters CSCI 240: Computing II

  4. C++ Character Set • a -- z • A -- Z • 0 -- 9 • , . ; : ? ! ' " ( ) [ ] • { } <>| / \ ~ + - = # % & ^ * CSCI 240: Computing II

  5. Identifiers • Name to denote Object, Function, Tag, typedef, Label or Macro • First character is alpha, followed by any number of alpha, numerals or an underscore. (Leading _ reserved for internal use.) • Case sensitive • Reserved words cannot be used CSCI 240: Computing II

  6. Attributes of Identifiers • Type • Visibility (Scope) • Uniqueness (Linkage) • Permanence (Duration) • Storage Class • Qualifier (Modifiability) CSCI 240: Computing II

  7. Type • Fundamental -- int, char, float, double, long, short, signed, unsigned • Derived -- arrays, functions, pointers, references, classes, unions, structures, enumerations CSCI 240: Computing II

  8. Scope • An Identifier can be Used within its Scope • File Scope – Global (C) • Class Scope -- Member of a Class (C++) • Function -- Labels (C) • Local -- Inside a Block (C) CSCI 240: Computing II

  9. Linkages • Bindings between identifiers • External • “extern” – not local to a file (means not allocated here) • Internal • local to a file – e.g., “static” • No linkage • e.g., classes, enumerations – must be unique across all files (#ifndef, #define, #endif used to control this) CSCI 240: Computing II

  10. Storage Duration • Static • Storage assigned once before the program startup, initialized only once, exists throughout the program • Automatic • Storage assigned in a block, their status is completely undefined after the completion of the block where they were defined CSCI 240: Computing II

  11. Storage Class • Auto – default – automatic variables • Extern – external objects • Register – internal auto variables stored in hardware registers – fast access (advisory) • Static – in a block, a file or a class CSCI 240: Computing II

  12. Qualifiers • No qualifier – default – alteration allowed • Const – no alteration is allowed CSCI 240: Computing II

  13. Acknowledgements • These slides were originally produced by Rajeev Raje, modified by Dale Roberts. CSCI 240: Computing II

More Related