現在vista+VC++2008EEでプログラミングしているのですが不明な点があったので質問させていただきます。
関数オブジェクトについてなのですが、int型で作った関数オブジェクトを関数ポインタのようにint型の配列に代入して使用することはできないのでしょうか?
試しにやってみたのですが期待どおりの動作をしてくれませんでした。
試したときのソース載せておきます。
//--bullet.h--
#pragma once
#include "header.h"
#include "class.h"
class AroundShot
{
public:
int operator()(int);
};
class Bullet : public Object
{
private:
static const int shot_num=1;
int player;
int power;
int type;
int img;
public:
AroundShot AS;
int Shot_Set[shot_num];
Bullet(){}
Bullet(float x, float y, int lifemax, float angle, int r, float speed, int power, int player);
Bullet(const Bullet ©, const Object &O_copy);
~Bullet();
virtual void Move();
};
extern std::vector<Bullet> bullet;
//--Bulletのコンストラクタ--
Bullet::Bullet(float x, float y, int lifemax, float angle, int r, float speed, int power, int player) :
Object(x, y, lifemax, angle, r, 0), power(power), player(player), type(::player[playe[/url].multi), img(Bullet_Img[playe[/url][::player[playe[/url].multi])
{
/*
this->power=power;
this->player=player;
this->type=::player[playe[/url].multi;
this->img=Player_Img[playe[/url][::player[playe[/url].multi];
*/
Shot_Set[0]=AS(0);
GetGraphSize(img, &w, &h);
this->w/=2;
this->h/=2;
}
//AroundShot
int AroundShot::operator()(int)
{
printfDx("ASop was used");
return(0);
}
while(ProcessMessage() == 0&&GetHitKeyStateAll(key) == 0){
ClsDrawScreen(); //裏画面のデータを全て削除
fps.FPS_Wait();//フレームの待機を計算
//実際の処理を入れる(初期化などを除く
switch(state)
{
case TITLE:
state=SELECT;
break;
case SELECT:
player[0]=Player(0, 0, 100, border_x/2, 400, 100, 0, 3, 5, 3, 0, 0);
player[1]=Player(1, 0, 100, border_x/2, 80, 100, 180, 3, 5, 3, 0, 0);
bullet[0].Move();
bullet[0].Shot_Set[0];
//printfDx("%d",bullet[0].AS(1));
ScreenFlip();
state=MAIN;
break;
}
fps.Draw_FPS();
ScreenFlip(); //裏画面データを表画面へ反映
}
#題名忘れてました。