-1
#include "2d/Vector2D.h"
#include <list>
#include "../../AbstTS.h"


class AbstRB;

class fTS: public AbstTS
{

public:

   fTS(AbstRB* owner);

   void       Update();
   void       closestBotStrategy();


};

class fGCBS
{

public:

    fGCBS(AbstRaven_Bot* owner);

    void       pickTarget();
 };


#endif

以上是我的代码,我想从 fTS 类中的 fGCBS 类访问 pickTarget() 。我知道我必须创建这个 fGCBS 的实例,但我不知道该怎么做,感谢您的帮助

4

2 回答 2

1

To create an instance of a class, you need to call its constructor.

于 2013-04-08T14:40:11.090 回答
0

One way would be to include an instance of fGCBS inside fTS.

class fTS: public AbstTS
{

public:

   fTS(AbstRaven_Bot* owner);

   void       Update();
   void       closestBotStrategy();
private:
   fGCBS my_fGCBS; // instance of fGCBS inside fTS
};

You would have to make a few other changes to your code for this to work. See if you can work them out.

于 2013-04-08T14:40:41.063 回答