Advertisement
hnOsmium0001

radians

Jan 22nd, 2020
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. struct RadiansImpl {
  5.     static RadiansImpl INSTANCE;
  6. };
  7. double operator-(double deg, RadiansImpl radImpl) {
  8.     return deg / 180.0 * M_PI;
  9. }
  10. #define degrees -RadiansImpl::INSTANCE
  11.  
  12. struct DegreesImpl {
  13.     static DegreesImpl INSTANCE;
  14. };
  15. double operator-(double rad, DegreesImpl degImpl) {
  16.     return rad / M_PI * 180.0;
  17. }
  18. #define radians -DegreesImpl::INSTANCE
  19.  
  20. int main() {
  21.   std::cout << "Hello World!\n";
  22.   std::cout << 90 degrees << "\n";
  23.   std::cout << M_PI radians << "\n";
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement