Lecture Programming in C++ - Chapter 18: Miscellaneous topics

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. | Chapter 18 – Miscellaneous Topics Multiple File Programs Makes 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 Using Header Files Header file is source code file Inserted into program source code before program compiled Can create own header files Option of having separate files for class definitions, implementations, and main Placed in different header files and use #include Lesson Working With Header Files Creating header file Source code file with extension .h Including header files #include “” Header file contents Put each class definition and each class implementation in separate files Lesson Header File Contents Three lines needed Two at top and one at bottom Messages to preprocessor and not compiled #ifndef name_h #define name_h source code #endif Lesson Preprocessor Directives #ifdef True if . | Chapter 18 – Miscellaneous Topics Multiple File Programs Makes 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 Using Header Files Header file is source code file Inserted into program source code before program compiled Can create own header files Option of having separate files for class definitions, implementations, and main Placed in different header files and use #include Lesson Working With Header Files Creating header file Source code file with extension .h Including header files #include “” Header file contents Put each class definition and each class implementation in separate files Lesson Header File Contents Three lines needed Two at top and one at bottom Messages to preprocessor and not compiled #ifndef name_h #define name_h source code #endif Lesson Preprocessor Directives #ifdef True if identifier defined in previous preprocessor #if True block executed if constant expression following is true #else Forms false block for #if #endif Marks end of conditional inclusion #ifndef True if identifier NOT defined previously #elif Works similar to “else if” #undef Undefines previously defined identifier Lesson Another Method More efficient connecting files with IDE Integrated Development Environment Save correctly working files as object code Link after all changes have been recompiled Lesson Bitwise Manipulations Very low-level operations Manipulate individual bits (1s and 0s) C++ provides bitwise operators Six operators Bit values set if value is 1 clear if value is 0 Lesson Why Use Bitwise Operators To control peripherals To use as flags Use individual bits instead of integers File encryption Array handling for any array that has members with only two possible states Lesson Bitwise Operators AND & Inclusive OR | Exclusive OR ^ Also called XOR Complement ~ .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.