Here is a header file in which I declare and define the class "Sebba": (My character)
class Sebba
{
public:
int GetHealth(int x);
private:
int Health;
};
int Sebba::GetHealth(int x)
{
return Health;
}
And here is the start of a C++ Source Code that I'm using in the game:
1.#include <iostream.h>
2.#include "header.h"
3.main()
4.{
5.Sebba obj;
6.cout << obj.GetHealth(5);
7.return 0;
8.}
As you can see, an intenger value is passed through the GetHealth() funcion. What's giving me troubles is this:
On line 6 of my source code, I want obj.Health's value to be printed to the screen. The GetHealth() Function is supposed to have the value 5 passed into it, return it, and print it to the screen. I expected it to print "5" to the screen. Much to my surprise, it printed out "4370436". I tried fixing this by changing intenger types, but after a lot of trouble and headaches, I still can't possibly imagine why it's printing out this number instead of 5. Can someone please help me figure out what's going on here?