Visual C++ 2005 系列课程学习笔记-4

Visual C++ 2005Visual C#的对比(委托的使用)

 

Visual C++ 2005:

 

interface class IShape

{

     void Draw();

}

 

ref class Circle:IShape

{

     Point center;

     int radius;

     void draw();

};

 

Circle^ c = gcnew Circle();

 

delegate void MyDelegate();

 

MyDelegate^ d = gcnew MyDelegate(c , &Circle::Draw)

 

Visual C#:

 

Interface IShape

{

     void Draw();

}

 

class Circle:IShape

{

     Point center;

     int radius;

     void draw();

};

 

Circle* c = new Circle();

 

delegate void MyDelegate();

 

MyDelegate d = new MyDelegate(c->Draw)

你可能感兴趣的:(Visual C++ 2005 系列课程学习笔记-4)