Advertisement
Guest User

Example

a guest
Apr 7th, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. //main.cpp:
  2.  
  3. #include <iostream>
  4. #include <string>
  5. #include "test.h"
  6.  
  7. int main()
  8. {
  9.     std::string s = "We ";
  10.     test t(s);
  11.     std::cout << s;
  12. }
  13.  
  14. //test.h:
  15.  
  16. #include <string>
  17.  
  18. class test {
  19. public:
  20.     test(std::string& s);
  21.     std::string store;
  22. };
  23.  
  24. //test.cpp:
  25.  
  26. #include "test.h"
  27. #include <iostream>
  28.  
  29. test::test(std::string& s) {
  30.     store = s;
  31.     store += "added this";
  32.     s += "injected this";
  33.     std::cout << store << std::endl;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement