| | |
header file and variable declaring problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 30
Reputation:
Solved Threads: 0
My main code variable declaration (just declaration no login statement)
==================================================
This code will be called under "header.h" (my subfunction in another .c file)
PROBLEM:
`ARCHER' was not declared in this scope
`archer' was not declared in this scope
SO:
what is the way i have to declare variable...
or my header file calling method has problem?
thx for help
C++ Syntax (Toggle Plain Text)
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;}; #include "header.h" / have to under struct... so that the struct has been declared int main(int argc, char *argv[]) { struct AXEMAN axeman; struct DEFENDER defender; struct ARCHER archer; struct ROUGE rouge; struct SPEARMAN spearman; string input; int sel_MainMenu=99,sel_GameMenu=99,sel_SubGameMenu=99,sel_Motion=99; int sel_Movement_num=99; char sel_Movement; int sel_char_num=99,sel_enermy_num=99; char sel_char,sel_enermy; int comp_dmg,player_dmg,comp_hp,player_hp; int quit=0; int error=0; char matrix[70][50]; //x=70 , y=50 int x,y; bool detected_comp=0,detected_player=0,skip=0;
This code will be called under "header.h" (my subfunction in another .c file)
C++ Syntax (Toggle Plain Text)
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; }
PROBLEM:
`ARCHER' was not declared in this scope
`archer' was not declared in this scope
SO:
what is the way i have to declare variable...
or my header file calling method has problem?
thx for help
•
•
•
•
C++ Syntax (Toggle Plain Text)
struct AXEMAN axeman; struct DEFENDER defender; struct ARCHER archer; struct ROUGE rouge; struct SPEARMAN spearman;
...Edit:: I don't get what you mean, do you have compiler errors ? (please post them if so)
Last edited by tux4life; Apr 19th, 2009 at 12:39 pm.
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
•
•
Join Date: Mar 2008
Posts: 30
Reputation:
Solved Threads: 0
subfunction.cpp:16: error: variable or field `initialize_status_player' declared void
subfunction.cpp:16: error: `AXEMAN' was not declared in this scope
subfunction.cpp:16: error: `axeman' was not declared in this scope
subfunction.cpp:16: error: `DEFENDER' was not declared in this scope
subfunction.cpp:16: error: `defender' was not declared in this scope
subfunction.cpp:16: error: `ARCHER' was not declared in this scope
subfunction.cpp:16: error: `archer' was not declared in this scope
subfunction.cpp:16: error: `SPEARMAN' was not declared in this scope
subfunction.cpp:16: error: `spearman' was not declared in this scope
subfunction.cpp:16: error: `ROUGE' was not declared in this scope
subfunction.cpp:16: error: `rouge' was not declared in this scope
subfunction.cpp:17: error: initializer expression list treated as compound expression
subfunction.cpp:17: error: expected `,' or `;' before '{' token
subfunction.cpp:35: error: variable or field `initialize_status_comp' declared void
subfunction.cpp:35: error: `AXEMAN' was not declared in this scope
subfunction.cpp:35: error: `axeman' was not declared in this scope
subfunction.cpp:35: error: `DEFENDER' was not declared in this scope
subfunction.cpp:35: error: `defender' was not declared in this scope
subfunction.cpp:35: error: `ARCHER' was not declared in this scope
subfunction.cpp:35: error: `archer' was not declared in this scope
subfunction.cpp:35: error: `SPEARMAN' was not declared in this scope
subfunction.cpp:35: error: `spearman' was not declared in this scope
subfunction.cpp:35: error: `ROUGE' was not declared in this scope
subfunction.cpp:35: error: `rouge' was not declared in this scope
subfunction.cpp:36: error: initializer expression list treated as compound expression
subfunction.cpp:36: error: expected `,' or `;' before '{' token
subfunction.cpp: In function `void initialize_weapon(char (*)[50])':
subfunction.cpp:61: error: `random_weapon' undeclared (first use this function)
subfunction.cpp:61: error: (Each undeclared identifier is reported only once for each function it appears in.)
these are part of the error only..
subfunction.cpp:16: error: `AXEMAN' was not declared in this scope
subfunction.cpp:16: error: `axeman' was not declared in this scope
subfunction.cpp:16: error: `DEFENDER' was not declared in this scope
subfunction.cpp:16: error: `defender' was not declared in this scope
subfunction.cpp:16: error: `ARCHER' was not declared in this scope
subfunction.cpp:16: error: `archer' was not declared in this scope
subfunction.cpp:16: error: `SPEARMAN' was not declared in this scope
subfunction.cpp:16: error: `spearman' was not declared in this scope
subfunction.cpp:16: error: `ROUGE' was not declared in this scope
subfunction.cpp:16: error: `rouge' was not declared in this scope
subfunction.cpp:17: error: initializer expression list treated as compound expression
subfunction.cpp:17: error: expected `,' or `;' before '{' token
subfunction.cpp:35: error: variable or field `initialize_status_comp' declared void
subfunction.cpp:35: error: `AXEMAN' was not declared in this scope
subfunction.cpp:35: error: `axeman' was not declared in this scope
subfunction.cpp:35: error: `DEFENDER' was not declared in this scope
subfunction.cpp:35: error: `defender' was not declared in this scope
subfunction.cpp:35: error: `ARCHER' was not declared in this scope
subfunction.cpp:35: error: `archer' was not declared in this scope
subfunction.cpp:35: error: `SPEARMAN' was not declared in this scope
subfunction.cpp:35: error: `spearman' was not declared in this scope
subfunction.cpp:35: error: `ROUGE' was not declared in this scope
subfunction.cpp:35: error: `rouge' was not declared in this scope
subfunction.cpp:36: error: initializer expression list treated as compound expression
subfunction.cpp:36: error: expected `,' or `;' before '{' token
subfunction.cpp: In function `void initialize_weapon(char (*)[50])':
subfunction.cpp:61: error: `random_weapon' undeclared (first use this function)
subfunction.cpp:61: error: (Each undeclared identifier is reported only once for each function it appears in.)
these are part of the error only..
•
•
Join Date: Mar 2008
Posts: 30
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
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;}; #include "header.h" / have to under struct... so that the struct has been declared int main(int argc, char *argv[]) { struct AXEMAN axeman; struct DEFENDER defender; struct ARCHER archer; struct ROUGE rouge; struct SPEARMAN spearman; string input; int sel_MainMenu=99,sel_GameMenu=99,sel_SubGameMenu=99,sel_Motion=99; int sel_Movement_num=99; char sel_Movement; int sel_char_num=99,sel_enermy_num=99; char sel_char,sel_enermy; int comp_dmg,player_dmg,comp_hp,player_hp; int quit=0; int error=0; char matrix[70][50]; //x=70 , y=50 int x,y; bool detected_comp=0,detected_player=0,skip=0; initialize_board(matrix); //Get Random comp hero initialize_status_player(axeman, defender, archer, spearman, rouge); //initialize hero's status introduce(); MainMenu(); //Get the selection of Main Menu while (sel_MainMenu==99) { input=Input(); sel_MainMenu=errorCheck_num (input); show_error (sel_MainMenu); } if(sel_MainMenu==1) //If MAIN MENU SELECTION == 1 (new game) { initialize_weapon(matrix); initialize_body (matrix); } else if (sel_MainMenu==2) load (axeman, defender, archer, spearman, rouge); else { cout<<"Bye bye...\n\n\n"; quit=1; }
C++ Syntax (Toggle Plain Text)
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; } void initialize_status_comp(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; } void initialize_weapon(char matrix[][50]) { matrix[4][17]=')'; matrix[4][22]='p'; matrix[4][27]='>'; matrix[4][32]=']'; matrix[4][37]='}'; matrix[55][17]=random_weapon (); matrix[55][22]=random_weapon (); matrix[55][27]=random_weapon (); matrix[55][32]=random_weapon (); matrix[55][37]=random_weapon (); }
C++ Syntax (Toggle Plain Text)
void initialize_status_player(AXEMAN &axeman, DEFENDER &defender, ARCHER &archer, SPEARMAN &spearman, ROUGE &rouge); void initialize_board(char matrix[][50]); void initialize_weapon(char matrix[][50]);
1st code block is my main.c
2nd code block is my subfunction.c
3rd code block is my header.h
Is this actually your whole code as I can't seem to find the following functions:
> introduce();
> MainMenu();
> Input();
> errorCheck_num (input);
> show_error (sel_MainMenu);
> initialize_body (matrix);
> load (axeman, defender, archer, spearman, rouge);
In the code you posted, the main-function is missing a '}' at the end ...
> introduce();
> MainMenu();
> Input();
> errorCheck_num (input);
> show_error (sel_MainMenu);
> initialize_body (matrix);
> load (axeman, defender, archer, spearman, rouge);
In the code you posted, the main-function is missing a '}' at the end ...
"Never argue with idiots, they just drag you down to their level and then beat you with experience."
![]() |
Similar Threads
- Strange problem (C++)
- Pointer to Member Function (C++)
- Problem declaring class object array (C++)
- only a couple of hours to go... (C++)
- Reading an input file as a class memeber function (C++)
Other Threads in the C++ Forum
- Previous Thread: Please I want someone to help me
- Next Thread: Wav file manipulation
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code compile compiler console conversion convert count data delete deploy dll download dynamic dynamiccharacterarray encryption error file format forms fstream function functions game givemetehcodez graph gui homeworkhelp iamthwee ifstream input int java lib library linkedlist linker list loop looping loops map math matrix memory microsoft newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template templates test text text-file tree url variable vector video visual visualstudio void win32 windows winsock wordfrequency wxwidgets






