#include "main.h"
using namespace std;
void update(Charactor* pc,Charactor* pe){
cout << " X " <<pc->GetPointX() << " Y " <<pc->GetPointY() << endl;
}
//object
void Object_Base::Initialize(){
cout<<"Object_Base I"<<endl;
}
void Object_Base::Update(){
cout<<"Object_Base U"<<endl;
}
void Object_Base::Draw(){
cout<<"Object_Base D"<<endl;
}
void Object_Base::Finalize(){
cout<<"Object_Base F"<<endl;
}
//charactor
Charactor::Charactor(int x,int y){
pos.x = x;
pos.y = y;
}
void Charactor::Initialize(){
cout<<"Charactor I"<<endl;
}
void Charactor::Update(){
cout<<"Charactor U"<<endl;
}
void Charactor::Draw(){
cout<<"Charactor D"<<endl;
}
void Charactor::Finalize(){
cout<<"Charactor F"<<endl;
}
t_pos Charactor::GetPoint(){
cout<<"Charactor GetPoint"<<endl;
return pos;
}
int Charactor::GetPointX(){
cout<<"Charactor GetPointX"<<endl;
return pos.x;
}
int Charactor::GetPointY(){
cout<<"Charactor GetPointY"<<endl;
return pos.y;
}
void Charactor::PrintData(int x){
cout << "Charactor Data" << x <<endl;
}
void* Charactor::GetPointer(){
return this;
}
//player
Player::Player(int x,int y){
pos.x=x;
pos.y=y;
}
void Player::Initialize(){
cout<<"Player I"<<endl;
}
void Player::Update(){
cout<<"Player U"<<endl;
}
void Player::Draw(){
cout<<"Player D"<<endl;
}
void Player::Finalize(){
cout<<"Player F"<<endl;
}
t_pos Player::GetPoint(){
cout<<"Player GetPoint"<<endl;
return pos;
}
int Player::GetPointX(){
cout<<"Player GetPointX"<<endl;
return pos.x;
}
int Player::GetPointY(){
cout<<"Player GetPointY"<<endl;
return pos.y;
}
//Enemy
Enemy::Enemy(int x,int y){
pos.x=x;
pos.y=y;
}
void Enemy::Initialize(){
cout<<"Enemy I"<<endl;
}
void Enemy::Update(){
cout<<"Enemy U"<<endl;
}
void Enemy::Draw(){
cout<<"Enemy D"<<endl;
}
void Enemy::Finalize(){
cout<<"Enemy F"<<endl;
}
t_pos Enemy::GetPoint(){
cout<<"Enemy GetPoint"<<endl;
return pos;
}
int Enemy::GetPointX(){
cout<<"Enemy GetPointX"<<endl;
return pos.x;
}
int Enemy::GetPointY(){
cout<<"Enemy GetPointY"<<endl;
return pos.y;
}
void* Enemy::GetPointer(){
return this;
}
int main(){
Charactor *charactor[5];
charactor[0] = new Player(10,20);
charactor[1] = new Enemy(25,30);
charactor[2] = new Player(75,51);
charactor[3] = new Enemy(54,41);
charactor[4] = new Player(25,30);
charactor[0] = (Charactor*)(charactor[1]->GetPointer());
for(int i = 0;i < 5;i++){
charactor[i]->Initialize();
charactor[i]->Update();
cout<<charactor[i]->GetPointX()<<endl;
cout<<charactor[i]->GetPointY()<<endl;
charactor[i]->Draw();
charactor[i]->PrintData(charactor[i]->GetPointX());
cout << "--------------------------" << endl;
}
}
また、void*は汎用ポインタときき使ってみましたが、どういう振る舞いをするのでしょうか??
実行例ではきちんと動いていたので、エラーがあるなどでは、有りません。