プログラムを別々のファイルに分割したいのですがやり方がわかりません。
Posted: 2011年10月12日(水) 20:09
次のようにmain.cppで全て定義していますが、
EnemyA001()~EnemyA100()はmain.cppとは別のEnemyA.cppに分けたいです。
ただし、変数playerは、main.cpp、EnemyA.cppの両方からアクセスできるようにしたいです。
自分なりに考えて、変数playerをglobal.hに定義し、main.cpp、EnemyA.cppの両方から呼び出しましたが、「再定義された」とエラーが出ます。どうすればいいか分かりません。どなたか教えてください。
main.cpp-------------------------------------------
int player;
int pattern;
int EnemyA001();
int EnemyA002();
int EnemyA003();
・・・(省略)
int EnemyA100();
EnemyA001()~EnemyA100()はmain.cppとは別のEnemyA.cppに分けたいです。
ただし、変数playerは、main.cpp、EnemyA.cppの両方からアクセスできるようにしたいです。
自分なりに考えて、変数playerをglobal.hに定義し、main.cpp、EnemyA.cppの両方から呼び出しましたが、「再定義された」とエラーが出ます。どうすればいいか分かりません。どなたか教えてください。
main.cpp-------------------------------------------
int player;
int pattern;
int EnemyA001();
int EnemyA002();
int EnemyA003();
・・・(省略)
int EnemyA100();