Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iostream>
- struct Index {
- Index(int i) : i_(i) {}
- int i_;
- };
- Index operator*(Index &I)
- {
- return I;
- }
- int operator*(int i, Index I)
- {
- return std::pow(i,I.i_);
- }
- int main()
- {
- Index I(2);
- std::cout << 2**I << std::endl; // prints 8
- }
Advertisement
Add Comment
Please, Sign In to add comment