/
Multiple Multiple

Multiple - PowerPoint Presentation

lois-ondreau
lois-ondreau . @lois-ondreau
Follow
371 views
Uploaded On 2016-04-30

Multiple - PPT Presentation

Files Monolithic vs Modular one file before system includes main driver function prototypes function definitions multiple files now main driver file prototypes header files functions definition implementation source files ID: 299395

file greet cpp include greet file include cpp main void function namespace std iostream user author clayton price comment

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "Multiple" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Multiple

FilesSlide2

Monolithic

vs Modular

one file beforesystem includesmain driver functionprototypesfunction definitions

multiple files now

main driver file

prototypes header file(s)

functions definition implementation source file(s)Slide3

#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(); Slide4

#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();#endifgreet.hmain.cpp

#include "

greet.h"

greet.cpp

void greetings()

{

    

cout

<< "Hello world!" <<

endl

;

    return;

} Slide5

#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();#endifgreet.hmain.cpp#include "greet.h"void greetings() {

    cout

<< "Hello world!" << endl

;    return;

}

greet.cppSlide6

Main File

comment header

system and user includesnamespace declarationmain 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.cppSlide7

Main File

comment header

system and user includesnamespace declarationmain 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.cppSlide8

Main File

comment header

system and user includesnamespace declarationmain 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.cppSlide9

Main File

comment header

system and user includesnamespace declarationmain 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.cppSlide10

Main File

comment header

system and user includesnamespace declarationmain 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.cppSlide11

Implementation File

comment header

user includefunction definitions

// Author: Clayton Price

// File: greet.cpp// This file provides the// greetings functionality#include "greet.h"void greetings() {    cout << "Hello world!" << endl;    return;} greet.cppSlide12

Implementation File

comment header

user includefunction definitions

// Author: Clayton Price

// File: greet.cpp// This file provides the// greetings functionality#include "greet.h"void greetings() {    cout << "Hello world!" << endl;    return;} greet.cppSlide13

Implementation File

comment header

user includefunction definitions

// Author: Clayton Price

// File: greet.cpp// This file provides the// greetings functionality#include "greet.h"void greetings() {    cout << "Hello world!" << endl;    return;} greet.cppSlide14

Implementation File

comment header

user includefunction definitions

// Author: Clayton Price

// File: greet.cpp// This file provides the// greetings functionality#include "greet.h"void greetings() {    cout << "Hello world!" << endl;    return;} greet.cppSlide15

Header File

comment header

preprocessor directivessystem and user includesnamespace declarationfunction 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.hSlide16

Header File

comment header

preprocessor directivessystem and user includesnamespace declarationfunction 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.hSlide17

Header File

comment header

preprocessor directivessystem and user includesnamespace declarationfunction 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.hSlide18

Header File

comment header

preprocessor directivessystem and user includesnamespace declarationfunction 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.hSlide19

Header File

comment header

preprocessor directivessystem and user includesnamespace declarationfunction 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.hSlide20

Header File

comment header

preprocessor directivessystem and user includesnamespace declarationfunction 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.hSlide21

Header File

comment header

preprocessor directivessystem and user includesnamespace declarationfunction prototypesdo 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.hSlide22

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 treesMultiple Files by Wildcardg++ -W –Wall –s –pedantic-errors *.cpp –o treesSlide23

Motivation

Security

PortabilityVersitiliyExtendability

#

ifndef GREET_H#define GREET_H#include <iostream>using namespace std;void greetings();#endif greet.h001010101001101010010100101010100110101001010010101010011010100101001010101001101010010100101010100110101001010010101010011010100101001010101001101010010100101010100110101001010010101010011010100101001010101001101010010100101010100110101001010010101010011010100Compiled greet.cppSlide24

End of Session