Skip to content

Instantly share code, notes, and snippets.

@varunagrawal
Last active August 29, 2015 14:02
Show Gist options
  • Save varunagrawal/bcaa251ff2c380051275 to your computer and use it in GitHub Desktop.
Save varunagrawal/bcaa251ff2c380051275 to your computer and use it in GitHub Desktop.
Demo of typedef for functions
#include <iostream>
#include <string>
using namespace std;
typedef short SmallNumber;
typedef unsigned int Positive;
typedef double Double;
typedef double (*Add)(double value1, double value2);
double Addition(double x, double y)
{
double result = x + y;
return result;
}
int main()
{
SmallNumber temperature = -248;
Positive height = 1048;
Double distance = new double(390.82);
Add plus;
plus = Addition;
cout << "3855.06 + 74.88 = " << plus(3855.06, 74.88) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment