Need help with header files

Hello I am currently working on personal project and this is my first time using multiple .cpp/.h files.

Here's main:

1
2
3
4
5
6
7
8
9
10
11
12
 #include <iostream>
#include "RPGcharcreator.h"
#include "RPGStats.h"

using namespace std;

int main()
{
    cout << "Hello world!" << endl;
    charcreat();
    return 0;
}


My errors is in this file, RPGcharcreator:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <string>
#include <string.h>
#include <fstream>
#include <cctype>
#include <locale>
#include <cstdlib>
#include "RPGStats.h"
#include "RPGcharcreator.h"

using namespace std;

int charcreat()
{

int class1 = 1; //warrior
/*int class2 = 2; //rogue
int class3 = 3; //wizard
int class4 = 4; //berserker
int class5 = 5; //monk
int class6 = 6; //warlock
int class7 = 7; //sage
int class8 = 8; //paladin
int class9 = 9; //sniper*/

string optionsetup = "";
string setupn = "n";
string setupy = "y";

setup:
cout << "Welcome to RPG! Please select the class for your 4 heroes you want for your\nadventure.\n" << endl;
system ("pause");

using hero1stats::hero1;
using hero2stats::hero2;
using hero3stats::hero3;
using hero4stats::hero4;

hero1setup:
cout << "Warrior(1)\nRogue(2)\nWizzard(3)\nBerserker(4)\nMonk(5)\nWarlock(6)\nSage(7)\nPaladin(8)\nSniper(9)\n" << endl;
cout << "The first heroes class: ";
cin >> hero1;

if (hero1 = 1)
{
cout << "********************************************************************************\n" <<endl;
cout << "The Warrior, an expert but not master in all melee weapons, this class gets a\nbonus to of +5 strength, +5 to all weapon skills, and can wield up to an armor\nclass of 4(plate armor) naturally." << endl;
h1setuprestart:
cout << "Is this the class you want? (y/n)" << endl;
cin >> optionsetup;
    if (optionsetup == setupy)
    {
    hero1 = class1;
    //place class bonus here
    }
    if (optionsetup == setupn)
    {
    goto hero1setup;
    }
    while(optionsetup != setupn && optionsetup != setupy){cout << "Invalid, command, please try again."<< endl; goto h1setuprestart;}
}

system ("pause");
return 0;
}


I get the error of "New declaration 'int charcreat()' in charcreate

and the error 'ambiguates old deceleration 'void charcreate()'in charcreator header file
1
2
3
4
5
6
7
8

#ifndef RPGCHARCREATOR_H
#define RPGCHARCREATOR_H

void charcreat();

#endif


And the header file where I'll keep hero and enemy stats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

#ifndef RPGSTATS_H
#define RPGSTATS_H

namespace hero1stats
  {
   int hero1 = 0;
   int h1lvl = 1;
   int h1str = 5;
   int h1agi = 5;
   int h1int = 5;
   int h1wis = 5;
   int h1lk = 5;
  }

namespace hero2stats
  {
  int hero2 = 0;
  int h2lvl = 1;
  int h2str = 5;
  int h2agi = 5;
  int h2int = 5;
  int h2wis = 5;
  int h2lk = 5;
  }

namespace hero3stats
  {
  int hero3 = 0;
  int h3lvl = 1;
  int h3str = 5;
  int h3agi = 5;
  int h3int = 5;
  int h3wis = 5;
  int h3lk = 5;
  }

namespace hero4stats
  {
  int hero4 = 0;
  int h1lvl = 1;
  int h1str = 5;
  int h1agi = 5;
  int h1int = 5;
  int h1wis = 5;
  int h1lk = 5;
  }

#endif
////////////////////////////////////////////////////////////////////////////////


I don't know what I'm doing wrong and would like some advice, this is my first time doing a long term large project. :P
New declaration 'int charcreat()' in charcreate
ambiguates old deceleration 'void charcreate()

In your header file: void charcreat();
In implementation file: int charcreat()
So, is it void or int?
I changed int charcreat() to void charcreat(), but now I get the message

error: return-statement with a value, in function returning 'void' [-fpermissive]|
Ok, let me guess. Now your charcreat function is defined as not returning anything (void), but you have return <something> inside?
Topic archived. No new replies allowed.