here are two examples of input into your c++ preprocessor. in each case the argu
ID: 3848682 • Letter: H
Question
here are two examples of input into your c++ preprocessor.
in each case the argument to your main method should be the
name of the first file, "file1.h" and the result file is
what your code should ultimately produce.
...............................File1
#include "file2.h"
//The contents of file 1 start here
Here are the contents of file1.h
//The contents of file 1 end here
..............................File2
#include "file3.h"
#include "file4.h"
//The contents of file 2 start here
Here are the contents of file2.h
//The contents of file 2 end here
................................File3
//The contents of file 3 start here
Here are the contents of file3.h
//The contents of file 3 end here
..................................File4
#include "file1.h"
//The contents of file 4 start here
Here are the contents of file4.h
//The contents of file 4 end here
............................................TestInput.
//The contents of file 3 start here
Here are the contents of file3.h
//The contents of file 3 end here
//The contents of file 4 start here
Here are the contents of file4.h
//The contents of file 4 end here
//The contents of file 2 start here
Here are the contents of file2.h
//The contents of file 2 end here
//The contents of file 1 start here
Here are the contents of file1.h
//The contents of file 1 end here
.........................................I need Help writing the code to this issue using the include statements to give the output like in the test.
Explanation / Answer
#include statements should not put like recursive.
if you put #include "file1.h" statement in file4.h, then it would be recursive. so, program will not compile.
file1.h
#include "file2.h"
#include <stdio.h>
void method1(){
printf("file1.h ");
}
file2.h
#include "file3.h"
#include "file4.h"
#include <stdio.h>
void method2(){
printf("file2.h ");
}
file3.h
#include <stdio.h>
void method3(){
printf("file3.h ");
}
file4.h
//#include "file1.h"
#include <stdio.h>
void method4(){
printf("file4.h ");
}
testinput.cpp
#include <stdio.h>
#include "file1.h"
int main(int arg,char *argv[]){
printf("testInput.cpp ---------------- ");
method3();
method4();
method2();
method1();
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.