ahmed0saber

Create and use my own header in C++

Nov 18th, 2020
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. Put the following code inside a file called something.hpp
  2.  
  3. #ifndef my_header
  4. #define my_header
  5. #include <iostream>
  6. using namespace std;
  7. square(int a)
  8. {
  9.     cout<<a*a;
  10. }
  11. #endif
  12.  
  13.  
  14.  
  15. Put the following code inside a cpp file
  16.  
  17. #include "something.hpp"
  18. int main()
  19. {
  20.     square(5);
  21. }
  22.  
  23.  
  24.  
  25. Make sure both the files are together in the same folder
Advertisement
Add Comment
Please, Sign In to add comment