C++ Funtion/Include Problems.
Hi to all, I'm new here!
I'll give you a quick rundown of what I am trying to achieve.
A short while ago, I set about learning my first scrap of C++ coding, And have manage to successfully code a few simple programs, such a quiz's, add libs, etc. Now I am starting on my very own game, an RPG. I know it's a lot to dive in to right now, but I'm determined at heart.
Anyway, What I have a problem with is the funtionality of things such as
#include <includefile.h> etc.
What I am trying to do, is simple. I want a header file, that contains the following -
Mana = Intelligence X 2
And another file, Orc, which passes the variable Intelligence, to the header file, then the header file returns the variable, Mana.
here's the code for the orc (orc.cpp)
Code:
//
// RPG ORC
//
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <statcheck.h>
#include <string.h>
using namespace std;
//Prototype Declarations
int main(int nNarg, char* pszArgs[])
{
int vitality = 10;
int strength = 10;
int intelligence = 2;
int hitpoints = 1;
cout << vitality << "\n";
cout << strength << "\n";
cout << intelligence << "\n";
cout << hitpoints << "\n";
//wait until user is ready before terminating the program
// to all user to see the program results
system("pause");
return 0;
}
And here's the code for the header file (statcheck.h)
Code:
//
// Mana
//
//
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string.h>
using namespace std;
int main(int intelligence)
{
int mana = intelligence * 2;
cout << mana << "\n";
//wait until user is ready before terminating the program
// to all user to see the program results
system("pause");
return 0;
}
I'm not sure what the heck i'm doing, so be kind :)