1 / 10

Learning Objectives

This text covers key learning objectives in C++ including bitwise operators, register storage class, conditional compilation, separate compilation, exception handling, and namespaces. It provides examples and explanations for each concept.

Download Presentation

Learning Objectives

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. Learning Objectives • What else in C++ • Bitwise operator • Register storage class • Conditional compilation • Separate compilation • Exception handling • Namespace

  2. Bitwise Operator • Binary Math • 0 + 0 = 0 • 0 + 1 = 1 • 1 + 1 = 10

  3. Bitwise Operator

  4. Register Storage Class • Example register int Miles; • Variable Miles is stored in register instead of main memory for quick access

  5. Conditional Compilation • You are trying to write a portable program for different compiler, operating system, or computer. • Example (delete file): unlink for Unix, remove for regular C library #ifdef Unix unlink(filename); #else remove(filename); #endif

  6. Conditional Compilation • Then, you could place the line #define Unix • at the top of the file when compiling under an old Unix system

  7. Separate Compilation • Divide one program into different header files and source code files • As we did in homework and project • During compilation, the system will replace #include “xxx.h” with the contents of “xxx.h” • Only compile once: save time • Also support conditional compilation

  8. Exception handling: Standard approach to handle errors void function_F() { Try { <do something> If(error condition) throw exception; <do something> } Catch (MyException e) { <Handle exception>} }

  9. Namespace • A namespace is a collection of name definitions, such class definition, variable declarations, and function definitions #include <iostream> using namespace std; Place all the name definitions (for example, cin, cout) into std name space and use this space

  10. Namespace • With namespace, you can • Redefine the existing names (functions, classes, variables) such as cin, cout • You need to create a new space for them • Assign one name (function, class, variable) with different definitions • You need to create separate spaces for them

More Related