![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 | |
|
Professional Programmer
|
.H and .CPP files
Lets say i have a header named Experience.h and another one named fight.h, they are both compiled in the same project.dev file, so if i have an integer in the experience.h called int exp;.. would the fight.h "interact" with the experience.h file? heres an example as best i can come up with without having tried it yet:
This is the fight.h: void fight()
{
cout << "you killed the monster.";
if (player_1.health > frog.health){
exp = exp + 15;
else if (player_1.health < frog.health) {
cout << "You died.";
}
}Experience.h: void experience()
{
int exp = 0;
if (exp == 400){
cout << "You have gained a level!";
}
}So what is happening is that the exp int is being created in the experience.h, but i need to know if it will also interact with other .h and .cpp files, since it is in the same project. If they do interact, i also would like to know if the int would be carried over to other .cpp's, like.. if int exp gained 20 in the main.cpp, if i printed the int from the experience.h would it have printed 20 aswell or would it be different values? If this doesnt make sense, just diregard it im very tired and will probably understand what im trying to do in the morning. EDIT: I forgot to add, would i have to create all the variables i want to be used across all the .cpp and headers as a global variable in the main .cpp?
__________________
▄▄▄▄ Quote:
Due to incorrect calculations during the middle ages, our calendar actually begins a few years after Jesus' birth. Thus the real 6/6/6 happened a few years back. The world already ended and you missed it. Download Code::Blocks now! ▄▄▄▄ |
|
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|