Generic Function Restrictions : generic parameters « Function « C++






Generic Function Restrictions

   
#include <iostream>
#include <cmath>
using namespace std;
   
void myfunc(int i)
{
  cout << "value is: " << i << "\n";
}
   
void myfunc(double d)
{
  double intpart;
  double fracpart;
   
  fracpart = modf(d, &intpart);
  cout << "Fractional part: " << fracpart;
  cout << "\n";
  cout << "Integer part: " << intpart;
}
   
int main()
{
  myfunc(1);
  myfunc(12.2);
   
  return 0;
}
  
    
    
  








Related examples in the same category

1.Cast generic parameters
2.template for value output
3.A Function with Two Generic Types
4.Applying Generic Functions: A Generic Bubble Sort
5.Generic function template