Last active
August 29, 2015 14:02
-
-
Save varunagrawal/bcaa251ff2c380051275 to your computer and use it in GitHub Desktop.
Demo of typedef for functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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