Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. himake: hello.o printing.o name.o
  2. g++ -o himake hello.o printing.o name.o
  3.  
  4. hello.o: hello.cpp
  5. g++ -c hello.cpp
  6.  
  7. printing.o: printing.cpp
  8. g++ -c printing.cpp
  9.  
  10. name.o: name.cpp
  11. g++ -c name.cpp
  12.  
  13. // hello.cpp
  14.  
  15. // standard library
  16. #include <iostream>
  17. #include <string>
  18. using namespace std;
  19.  
  20. // user defined header files
  21. #include "name.h"
  22. #include "printing.h"
  23.  
  24. int main ()
  25. {
  26. string name;
  27.  
  28. name = getName(); // getName is in name.h
  29. printHello(name); // printHello is in print.h
  30.  
  31. return 0;
  32. }
  33.  
  34. // printing.cpp
  35.  
  36. // user defined include files
  37. #include "printing.h"
  38.  
  39. void printGreeting(void)
  40. {
  41. cout << "Your name: ";
  42. return;
  43. }
  44.  
  45. void printHi (string name)
  46. {
  47. cout << "Hi, " << name << endl;
  48. return;
  49. }
  50.  
  51. // name.h
  52.  
  53. #include <iostream>
  54. using namespace std;
  55.  
  56. string getName();
  57.  
  58. // printing.cpp
  59.  
  60. // user defined include files
  61. #include "printing.h"
  62.  
  63. void printGreeting(void)
  64. {
  65. cout << "Your name: ";
  66. return;
  67. }
  68.  
  69. void printHi (string name)
  70. {
  71. cout << "Hi, " << name << endl;
  72. return;
  73. }
  74.  
  75. // printing.h
  76.  
  77. #include <iostream>
  78. using namespace std;
  79.  
  80. void printGreeting();
  81. void printHello(string);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement