http://cs.mst.edu multiple files. monolithic vs modular one file before system includes main...
TRANSCRIPT
![Page 1: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/1.jpg)
http://cs.mst.edu
Multiple Files
![Page 2: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/2.jpg)
http://cs.mst.edu
Monolithic vs Modular one file before
system includes main driver function prototypes function definitions
multiple files now main driver file prototypes header
file(s) functions definition
implementation source file(s)
![Page 3: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/3.jpg)
http://cs.mst.edu
#include <iostream>using namespace std;
int main(){ greetings(); return 0;}
void greetings() { cout << "Hello world!" << endl; return;}
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
#endif
greet.h
main.cpp
void greetings();
![Page 4: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/4.jpg)
http://cs.mst.edu
#include <iostream>#include “greet.h”using namespace std;
int main(){ greetings(); return 0;}
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
main.cpp
#include "greet.h"
greet.cpp
void greetings() { cout << "Hello world!" << endl; return;}
![Page 5: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/5.jpg)
http://cs.mst.edu
#include <iostream>#include “greet.h”using namespace std;
int main(){ greetings(); return 0;}
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
main.cpp
#include "greet.h"
void greetings() { cout << "Hello world!" << endl; return;}
greet.cpp
![Page 6: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/6.jpg)
http://cs.mst.edu
Main File comment header system and user includes namespace declaration main function
// Author: Clayton Price// File: main.cpp// This file drives the greet// function.
#include "greet.h"#include <iostream>
using namespace std;
int main(){ greetings(); cout << “Good bye” << endl; return 0;}
main.cpp
![Page 7: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/7.jpg)
http://cs.mst.edu
Main File comment header system and user includes namespace declaration main function
// Author: Clayton Price// File: main.cpp// This file drives the greet// function.
#include "greet.h"#include <iostream>
using namespace std;
int main(){ greetings(); cout << “Good bye” << endl; return 0;}
main.cpp
![Page 8: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/8.jpg)
http://cs.mst.edu
Main File comment header system and user includes namespace declaration main function
// Author: Clayton Price// File: main.cpp// This file drives the greet// function.
#include "greet.h"#include <iostream>
using namespace std;
int main(){ greetings(); cout << “Good bye” << endl; return 0;}
main.cpp
![Page 9: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/9.jpg)
http://cs.mst.edu
Main File comment header system and user includes namespace declaration main function
// Author: Clayton Price// File: main.cpp// This file drives the greet// function.
#include "greet.h"#include <iostream>
using namespace std;
int main(){ greetings(); cout << “Good bye” << endl; return 0;}
main.cpp
![Page 10: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/10.jpg)
http://cs.mst.edu
Main File comment header system and user includes namespace declaration main function
// Author: Clayton Price// File: main.cpp// This file drives the greet// function.
#include "greet.h"#include <iostream>
using namespace std;
int main(){ greetings(); cout << “Good bye” << endl; return 0;}
main.cpp
![Page 11: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/11.jpg)
http://cs.mst.edu
Implementation File comment header user include function definitions
// Author: Clayton Price// File: greet.cpp// This file provides the// greetings functionality
#include "greet.h"
void greetings() { cout << "Hello world!" << endl;
return;}
greet.cpp
![Page 12: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/12.jpg)
http://cs.mst.edu
Implementation File comment header user include function definitions
// Author: Clayton Price// File: greet.cpp// This file provides the// greetings functionality
#include "greet.h"
void greetings() { cout << "Hello world!" << endl;
return;}
greet.cpp
![Page 13: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/13.jpg)
http://cs.mst.edu
Implementation File comment header user include function definitions
// Author: Clayton Price// File: greet.cpp// This file provides the// greetings functionality
#include "greet.h"
void greetings() { cout << "Hello world!" << endl;
return;}
greet.cpp
![Page 14: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/14.jpg)
http://cs.mst.edu
Implementation File comment header user include function definitions
// Author: Clayton Price// File: greet.cpp// This file provides the// greetings functionality
#include "greet.h"
void greetings() { cout << "Hello world!" << endl;
return;}
greet.cpp
![Page 15: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/15.jpg)
http://cs.mst.edu
Header File comment header preprocessor directives system and user includes namespace declaration function prototypes
// Author: Clayton Price// File: greet.h// This file contains prototype// info for the greet program.//// Function: void greetings();// This function sends a hello// message to the user through// standard output
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
![Page 16: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/16.jpg)
http://cs.mst.edu
Header File comment header preprocessor directives system and user includes namespace declaration function prototypes
// Author: Clayton Price// File: greet.h// This file contains prototype// info for the greet program.//// Function: void greetings();// This function sends a hello// message to the user through// standard output
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
![Page 17: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/17.jpg)
http://cs.mst.edu
Header File comment header preprocessor directives system and user includes namespace declaration function prototypes
// Author: Clayton Price// File: greet.h// This file contains prototype// info for the greet program.//// Function: void greetings();// This function sends a hello// message to the user through// standard output
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
![Page 18: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/18.jpg)
http://cs.mst.edu
Header File comment header preprocessor directives system and user includes namespace declaration function prototypes
// Author: Clayton Price// File: greet.h// This file contains prototype// info for the greet program.//// Function: void greetings();// This function sends a hello// message to the user through// standard output
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
![Page 19: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/19.jpg)
http://cs.mst.edu
Header File comment header preprocessor directives system and user includes namespace declaration function prototypes
// Author: Clayton Price// File: greet.h// This file contains prototype// info for the greet program.//// Function: void greetings();// This function sends a hello// message to the user through// standard output
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
![Page 20: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/20.jpg)
http://cs.mst.edu
Header File comment header preprocessor directives system and user includes namespace declaration function prototypes
// Author: Clayton Price// File: greet.h// This file contains prototype// info for the greet program.//// Function: void greetings();// This function sends a hello// message to the user through// standard output
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
![Page 21: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/21.jpg)
http://cs.mst.edu
Header File comment header preprocessor directives system and user includes namespace declaration function prototypes do not do this!
// Author: Clayton Price// File: greet.h// This file contains prototype// info for the greet program.//// Function: void greetings();// This function sends a hello// message to the user through// standard output
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
#include “greet.cpp”
void greetings();
#endif
greet.h
![Page 22: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/22.jpg)
http://cs.mst.edu
Compiling Single File g++ -W –Wall –s –pedantic-errors prog.cpp –o my_prog
Multiple Files by Name g++ -W –Wall –s –pedantic-errors treeFarm.cpp treeFarmFunctions.cpp –o trees
Multiple Files by Wildcard g++ -W –Wall –s –pedantic-errors *.cpp –o trees
![Page 23: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/23.jpg)
http://cs.mst.edu
Motivation Security Portability Versitiliy Extendability
#ifndef GREET_H#define GREET_H
#include <iostream>using namespace std;
void greetings();
#endif
greet.h
001010101001101010010100101010100110101001010010101010011010100101001010101001101010010100101010100110101001010010101010011010100101001010101001101010010100101010100110101001010010101010011010100101001010101001101010010100101010100110101001010010101010011010100
Compiled greet.cpp
![Page 24: Http://cs.mst.edu Multiple Files. Monolithic vs Modular one file before system includes main driver function prototypes function](https://reader030.vdocuments.mx/reader030/viewer/2022032414/56649ef35503460f94c057ee/html5/thumbnails/24.jpg)
http://cs.mst.edu
End of Session