Lecture Programming in C++ - Chapter 18: Miscellaneous topics. On completion of this chapter students will know how to: Benefits of multiple file organization, how to use header files, how to use bitwise operators, how to work with binary files.
Trang 1Topics
Trang 2Makes possible to accommodate many
programmers working on same project
More efficient to manage large amount of source code
Can incorporate class libraries in separate files from independent vendors
Lesson 18.1
Trang 7More efficient connecting files with IDE
– Integrated Development Environment
Save correctly working files as object codeLink after all changes have been recompiled
Lesson 18.1
Trang 8Very lowlevel operations
Manipulate individual bits (1s and 0s)C++ provides bitwise operators
Trang 10Left shift <<
Lesson 18.2
Trang 12bitwise And / inclusive ORWork similar to counterparts && and ||
Trang 13Lesson 18.2
Bitwise AND Bitwise OR
hex 3 0 0 1 1 hex 3 0 0 1 1 & |
hex 6 0 1 1 0 hex 6 0 1 1 0 = =
&&&& | | | |
Trang 14~(1010) = 0101
Lesson 18.2
Trang 150 ^ 0 = 0 1 ^ 1 = 0
0 ^ 1 = 1 1 ^ 0 = 1
Lesson 18.2
Trang 17Can shift more than one bit
Bitwise operators can only be used on integer data types
All systems do NOT use same bitwise representations
– May get different results
Lesson 18.2
Trang 18Efficient since do not have to convert from ASCII
Trang 20Opening Input File for Reading in Binary
ifstream in_ob (“name”, ios :: in | ios :: binary);
programmerchosen input file object name
filename
Lesson 18.3
Trang 22Number of bytes to be copied from file to memory Operator that makes C++ interpret address
to represent beginning of an array of
characters
Trang 24Benefits of multiple file organizationHow to use header files
How to use bitwise operators
How to work with binary files