Advertisement
Guest User

Untitled

a guest
Jul 10th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. namespace {
  2. inline void better(); // give the function a unique name
  3. }
  4.  
  5. static inline void worse(); // kludge the linker to allowing duplicates
  6.  
  7. inline int Foo()
  8. {
  9. return 1;
  10. }
  11.  
  12. int Bar1()
  13. {
  14. return Foo();
  15. }
  16.  
  17. inline int Foo()
  18. {
  19. return 2;
  20. }
  21.  
  22. int Bar2()
  23. {
  24. return Foo();
  25. }
  26.  
  27. // file.h
  28. static void foo () {}
  29. struct A {
  30. static void foo () {}
  31. };
  32.  
  33. // file1.cpp
  34. #include"file.h"
  35. void x1 ()
  36. {
  37. foo(); // different function exclusive to file1.cpp
  38. A::foo(); // same function
  39. }
  40.  
  41. // file2.cpp
  42. #include"file.h"
  43. void x2 ()
  44. {
  45. foo(); // different function exclusive to file2.cpp
  46. A::foo(); // same function
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement