Iterator articles of football tactics

zhaozj2021-02-11  215

Connect to:

http://www.9cbs.net/develop/read_article.asp?id=11677

Using the Iterator mode, let each player make iterator, each location is made, there is a few benefits: 1. Each location supports different players in different ways. 2. Simplify the interfaces of each location, make it kiss, no interface with traversal. 3. Support multiple players at the same time traversal at the same location. The code is as follows: Template class {public: Location (long size = default _ position _ capacity); long count () const; item & get (long index) const; // ...};

Template Class player {public: Virtual void returns to the initial location () = 0; Virtual Void Next location () = 0; if the Virtual Bool arrives () const = 0; Virtual Item Current item () const = 0 protected: players ();

Template Class left defender: public player {public: Left defender (const position * 1 location); Virtual Void returns to the initial position; Virtual Void Next location (); Virtual Bool arrive ( CONST; Virtual Item Current Item () const; private: const position * _ position; long _ current;};

转载请注明原文地址:https://www.9cbs.com/read-5225.html

New Post(0)