Guest User

Untitled

a guest
Oct 28th, 2013
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <cmath>
  2. #include <iostream>
  3.  
  4. struct Index {
  5.         Index(int i) : i_(i) {}
  6.         int i_;
  7. };
  8.  
  9. Index operator*(Index &I)
  10. {  
  11.     return I;
  12. }
  13.  
  14. int operator*(int i, Index I)
  15. {                
  16.         return std::pow(i,I.i_);
  17. }
  18.  
  19. int main()
  20. {  
  21.         Index I(2);
  22.         std::cout << 2**I << std::endl;  // prints 8
  23. }
Advertisement
Add Comment
Please, Sign In to add comment