ECE244H1 Study Guide - Midterm Guide: Include Directive, Semicolon, Dereference Operator

77 views12 pages

Document Summary

Filename. cpp writes the implementation of the file. Filename. h writes the definition of the file. Remember to include the filename. h file in filename. cpp file. How to compile files in terminal g++ main. cc squared. cc squareroot. cc o myprog. exe. If run main. cc, file1. cc, file1. h once each, and file1. h has been modified after the compilation, we have to re-compile main. cc, file1. cc, and file1. h once again. Because main. cc and file1. cc both includes file. h. Multiple includes of the same file result in multiple definitions of the same function. Don"t include the same thing twice in the same . cpp / . cc file. To the . cpp and . h file to fix the problem. Prevents double declaration of header file (don"t include the same thing twice) Why shouldn"t include . cpp file but include . h file. #include tells the preprocessor to take the entire file programmer specified and copy it into active file before compiles to it.