fork download
  1. #include <iostream>
  2.  
  3. template <class coefs>
  4. double linear(double x) {
  5. return coefs::a * x + coefs::b;
  6. }
  7.  
  8. struct my_coefs
  9. {
  10. static const double a;
  11. static const double b;
  12. };
  13.  
  14. const double my_coefs::a = 2.0;
  15. const double my_coefs::b = 3.0;
  16.  
  17. int main()
  18. {
  19. std::cout << linear<my_coefs>(5.0) << std::endl;
  20. }
Success #stdin #stdout 0.01s 2724KB
stdin
Standard input is empty
stdout
13