Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
3.2.2 Giao diện [truy cập] giao diện tên {mã cơ thể} Giao diện mô tả hành vi của một lớp là một tập hợp các phương pháp, tài sản, và các sự kiện. Trong việc định nghĩa một giao diện tất cả các phương pháp và tài sản được đảm bảo thực hiện. giao diện là | 46 Applied C in Financial Markets string sql select contractsize from tblProduct where pSymbol base.symbol DBHandler db new DBHandler DataSet ds db.dbSelect sql Console.Write sql DataRow dr ds.Tables 0 .Rows 0 _derivAttrib.Add contract int dr contractSize 3.2.2 Interfaces access interface name code body Interfaces describe the behaviour of a class as a set of methods properties and events. In defining an interface all the methods and properties are guaranteed in the implementation. interface is a keyword used to define the interface in a similar way to how a class is defined. An abstract class is similar to an interface except it uses the abstract keyword in place of the interface keyword and for example an abstract class may contain non-virtual methods whereas an interface may only describe the methods. For a list of the important differences see Table 3.4. The big difference is that when it comes to implementation you may only inherit one class whereas you can inherit multiple interfaces. Implementing interfaces In this section interfaces are examined from a practical viewpoint and from the perspective of using inheritance in a financial application. In the Table 3.4 Differences between abstract classes and interfaces Description Abstract class Interface Keyword abstract interface May contain non-overridable methods Yes No Inheritance Single Multiple Instance variables Yes No Constructors Yes No Include private or protected methods Yes No Object Oriented Programming 47 last section we looked at the derivative products Options and Futures. As we have seen they have many common properties and behaviour but each product has specific features. Not surprisingly pricing futures and options are different but they do share some behaviour the options are priced using the Black Scholes model and the futures get their prices from an exchange feed. Both options and futures need some parameters to be able to get the price from either the model or a price feed and they both .