>main.cpp
#include <cstdlib>
#include <iostream>
using namespace std;
#include "function.h"
int main(int argc, char *argv[])
{
struct AXEMAN{
int lvl;
int att;
int hp;};
struct DEFENDER{
int lvl;
int att;
int hp;};
struct ARCHER{
int lvl;
int att;
int hp;};
struct SPEARMAN{
int lvl;
int att;
int hp;};
struct ROUGE{
int lvl;
int att;
int hp;};
struct AXEMAN axeman;
struct DEFENDER defender;
struct ARCHER archer;
struct ROUGE rouge;
struct SPEARMAN spearman;
char matrix[70][50];
initialize_board(matrix);
initialize_status_player(axeman, defender, archer, spearman, rouge);
system("PAUSE");
return EXIT_SUCCESS;
}
>function.h
void initialize_status_player(AXEMAN &axeman, DEFENDER &defender, ARCHER &archer, SPEARMAN &spearman, ROUGE &rouge);
void initialize_board(char matrix[][50]);
>function.cpp
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
void initialize_board(char matrix[][50])
{
for(int i=0;i<70;i++)
for(int j=0;j<50;j++)
{
matrix[i][j]=' ';
}
}
void initialize_status_player(AXEMAN &axeman, DEFENDER &defender, ARCHER &archer, SPEARMAN &spearman, ROUGE &rouge)
{
axeman. lvl=1;
axeman. att=40;
axeman. hp=450;
defender. lvl=1;
defender. att=30;
defender. hp=500;
archer. lvl=1;
archer. att=50;
archer. hp=300;
spearman. lvl=1;
spearman. att=45;
spearman. hp=400;
rouge. lvl=1;
rouge. att=35;
rouge. hp=350;
}
error log:
Compiler: Default compiler
Building Makefile: "D:\Documents and Settings\kiwi\My Documents\KIWI DOCUMENTS\my program\C++\test\New Folder\Makefile.win"
Executing make clean
rm -f test1.o addition.o show.o Project2.exe
g++.exe -c test1.cpp -o test1.o -I"C:/Program Files/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Program Files/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Program Files/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Program Files/Dev-Cpp/include/c++/3.4.2" -I"C:/Program Files/Dev-Cpp/include"
In file included from test1.cpp:5:
show.h:1: error: variable or field `initialize_status_player' declared void
show.h:1: error: `AXEMAN' was not declared in this scope
show.h:1: error: `axeman' was not declared in this scope
show.h:1: error: `DEFENDER' was not declared in this scope
show.h:1: error: `defender' was not declared in this scope
show.h:1: error: `ARCHER' was not declared in this scope
show.h:1: error: `archer' was not declared in this scope
show.h:1: error: `SPEARMAN' was not declared in this scope
show.h:1: error: `spearman' was not declared in this scope
show.h:1: error: `ROUGE' was not declared in this scope
show.h:1: error: `rouge' was not declared in this scope
show.h:1: error: initializer expression list treated as compound expression
test1.cpp: In function `int main(int, char**)':
test1.cpp:41: error: `initialize_status_player' cannot be used as a function
make.exe: *** [test1.o] Error 1
Execution terminated