All pastes #974916 Raw Edit

Something

public cpp v1 · immutable
·published 2008-04-07 04:05 UTC
rendered paste body
void main() {Delegate<string> nameFunctions;nameFunctions += SayHello;nameFunctions += SayGoodBye;//nameFunctions += PrintSum; // compiler error; PrintSum does not take a string as an argumentnameFunctions("John Doe");nameFunctions("Jane Doe");Delegate<int, int> numberFunctions;numberFunctions += PrintSum;numberFunctions += PrintDifference;numberFunctions(1,2);numberFunctions(2,2) /* Output isHello John DoeGoodbye John DoeHello Jane DoeGoodbye Jane DoeThe sum is 3The difference is -1The sum is 4The difference is 0 */}void SayHello(string name) {cout << " Hello " << name;}void SayGoodbye(string name) {cout << " Goodbye " << name;}void PrintSum(int number1, int number2) {cout << " The sum is " << number1 + number2;}void PrintDifference(int number1, int number2) {cout << "The difference is " << number1 - number2;}