Guest User

Untitled

a guest
Jul 29th, 2012
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. creating methods that doesn't depend on a object
  2. //functions.h
  3.  
  4. namespace MyFunctions
  5. {
  6. void foo();
  7. void goo();
  8. }
  9.  
  10. //functions.cpp
  11.  
  12. namespace MyFunctions
  13. {
  14. void foo() {}
  15. void goo() {}
  16. }
  17.  
  18. //functions.h
  19. inline void foo() {
  20. //..
  21. }
  22. inline void goo() {
  23. //..
  24. }
  25.  
  26. //fileThatUsesFunctions.cpp
  27.  
  28. namespace
  29. {
  30. void foo() {}
  31. void goo() {}
  32. }
  33.  
  34. namespace Utils
  35. {
  36. void myMethod();
  37. }
  38.  
  39. namespace Utils
  40. {
  41. void myMethod()
  42. {
  43. //Implementation
  44. }
  45. }
  46.  
  47. namespace Foo
  48. {
  49. publicFunction1();
  50. publicFunction2();
  51.  
  52. namespace
  53. {
  54. privateFunction1();
  55. std::vector<Bar> privateData;
  56. }
  57. }
  58.  
  59. // MyFile.h
  60. int some_function();
  61.  
  62. // MyFile.cpp
  63.  
  64. int some_function() {
  65. return 42;
  66. }
  67.  
  68. // MyFile.h
  69. namespace MyNamespace {
  70. int some_function();
  71. }
  72.  
  73. // MyFile.cpp
  74. using MyNamespace;
  75. int some_function() {
  76. return 42;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment