Problem with STD in string

Jun 24, 2013 at 10:26pm
I'm trying to make a small rpg out of text (don't mind the fact that it's not much right now.) I'll explain below:

main.cpp
1
2
3
4
5
6
7
8
9
  #include <iostream>
#include <cstdlib>
#include "header.h"
using namespace std;
int main()
{
	string battle (int enemrand);
	return 0;
}

Header.h
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <cstdlib>
#include "Header.h"
using namespace std;
int enemhealth = rand() % 100;
int enemrand = rand() % 3 - 2;
string battle = atoi(int enemrand)
{
cout<<enemrand<<" enemies have appeared!\n";
}

The program runs, but no text displays. I don't get it, what am I doing wrong?
Jun 24, 2013 at 10:41pm
The main function does nothing. It only contains a declaration of function battle which has parameter of type int and return type of std::string and that is all.
Jun 25, 2013 at 12:34am
Also you header contains some random code in the global space; I suspect you meant to define a function. I'm surprised you were able to get the program to run at all, as I would expect it to not even compile.
Jun 25, 2013 at 12:40am
This code would not compile as Header.h includes itself without any guard.
Jun 25, 2013 at 12:41am
Ah, actually I see now that main is including a header.h with a different capitalization, perhaps that's why it compiles for TC?
Topic archived. No new replies allowed.