Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Nov 29th, 2005, 2:46 AM   #1
jayme
Professional Programmer
 
jayme's Avatar
 
Join Date: Nov 2005
Location: Canada
Posts: 495
Rep Power: 0 jayme is an unknown quantity at this point
Send a message via MSN to jayme
.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:
Originally Posted by Mohamed Jihad
Durka durka!
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!
jayme is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:08 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC