// Delegate.cpp : main project file.

#include "stdafx.h"

using namespace System;

delegate double NumericOp(double);

ref class Ops
{
	public:
		static double square(double d)
		{  return d*d;  }
		static double cube(double d)
		{  return d*d*d; }
};

int main(array<System::String ^> ^args)
{
	// Declare a delegate
	NumericOp^ pOp = gcnew NumericOp(&Ops::square);
	// Declare a second delegate
	NumericOp^ pOp2 = gcnew NumericOp(&Ops::cube);

	// Call the function through the delegate
	double result = pOp->Invoke(3.0);
	Console::WriteLine(L"Result is {0}", (Object^)(result));

	// Call the function through the delegate
	double result2 = pOp2->Invoke(3.0);
	Console::WriteLine(L"Result of cube() is {0}", (Object^)(result2));
	
	return 0;
}
