Download presentation
Presentation is loading. Please wait.
Published byὈρέστης Νικολάκος Modified over 6 years ago
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; } 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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.