Use typedef to create new data type and use it as function return type : typedef « Development « C++ Tutorial






#include <cmath>
#include <iostream>
using namespace std;

typedef double NewType;

NewType f(double number);
NewType f2(double number);
NewType f3(double number);

int main()
{
       int menu;
       double num;
       NewType response;

    response = f(num);
    cout << "The answer is " << response;
    
    response = f2(num);
    cout << "The answer is " << response;
    
    response = f3(num);
    cout << "The answer is " << response;
       
       return 0;
}

NewType f(double number)
{
   return sqrt(number);
}
NewType f2(double number)
{
   return pow(number,.3333);
}
NewType f3(double number)
{
   return pow (number,.25);
}
The answer is 2.29873e-154The answer is 3.8421e-103The answer is 1.51616e-077"








5.23.typedef
5.23.1.Use typedef keyword to define new variable type
5.23.2.Use typedef to create new data type and use it as function return type