Advertisement
Guest User

Scoping

a guest
May 4th, 2014
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1.  
  2. namespace od
  3. {
  4. scope io
  5. {
  6. scope keyboard
  7. {
  8. scope constants
  9. {
  10. const int vk_space, vk_enter;
  11. }
  12.  
  13. bool keyCheck();
  14. bool keyPressed();
  15. bool keyReleased();
  16. }
  17.  
  18. scope mouse
  19. {
  20. scope constants
  21. {
  22. const int mb_left;
  23. }
  24. bool mousePressed();
  25. }
  26. }
  27.  
  28. string libraryVersion();
  29. }
  30.  
  31. using od.io.keyboard;
  32. unuse od.io.keyboard.constants;
  33.  
  34. {
  35. using od;
  36. // possibilité d'utiliser n'importe quelle fonction d'od:
  37. libraryVersion();
  38. keyPressed(vk_space);
  39. }
  40.  
  41. {
  42. using od.io;
  43. // possibilité d'utiliser toutes les fonctions du scope io contenu dans od
  44. libraryVersion(); // erreur
  45. keyPressed(vk_space); // ok
  46. }
  47.  
  48. {
  49. using od::keyPressed;
  50. // possibilité d'utiliser uniquement keyPressed
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement