For pattern, here s how you could sack up the niche class from the previous example implement the System::IComparable interface: ref class package : Container, IComparable // Derived class { public: // The function specify by IComparable interface virtual int CompareTo(Object^ obj) { if(Volume() < safe_cast(obj)->Volume()) picture -1; else if(Volume() > safe_cast(obj)->Volume()) return 1; else return 0; } // Rest of the class as before... }; The quote of the interface follows the get off up of the base class, Container . If on that point were no base class, the interface disclose alone wo uld appear here. A ref class fecal matter ! only have one base class, but it outhouse implement as many interfaces as you want. The class must defi ne every function specifi ed by each of the interfaces that it claims to implement. The IComparable interface only specifi es one function, but there can be as many functions in an interface as you want. The Box class now defi nes the CompareTo() function with the same signature as the IComparable interface specifi es for the function....If you want to get a all-inclusive essay, order it on our website: OrderCustomPaper.com
If you want to get a full essay, visit our page: write my paper
No comments:
Post a Comment