more text based game trouble!

I've got 5 files:

main.cpp

character.h
character.cpp

storyboard.h
storyboard.cpp

when i run, i get this error form the linker:

ld: duplicate symbol _user in /Users/bstephens129/Library/Developer/Xcode/DerivedData/full_rpg_text_based-hfrarhgxxzksdfcplpkbmbvolusb/Build/Intermediates/full_rpg_text_based.build/Debug/full_rpg_text_based.build/Objects-normal/x86_64/storyboard.o and /Users/bstephens129/Library/Developer/Xcode/DerivedData/full_rpg_text_based-hfrarhgxxzksdfcplpkbmbvolusb/Build/Intermediates/full_rpg_text_based.build/Debug/full_rpg_text_based.build/Objects-normal/x86_64/main.o for architecture x86_64
Command /Developer/usr/bin/clang++ failed with exit code 1

it says im double-declaring 'user,' but i dont see anywhere that could be happening... help!


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

using namespace std;

int main (int argc, const char * argv[])
{

    sleep(1);
    storyboard::cutscene(1);
    return 0;
}


character.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef full_rpg_text_based_character_h
#define full_rpg_text_based_character_h


#include <strings.h>

using namespace std;

class character 
{
public:
    
    string name;
    int force;
    int block;
    int stamina;
    
    static void create_user(string nme, int frc, int blk, int sta);
};

character user;

#endif


character.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13

#include <iostream>

#include "character.h"

void character::create_user(string nme, int frc, int blk, int sta)
{
    
    user.name = nme;
    user.force = frc;
    user.block = blk;
    user.stamina = sta;
}


storyboard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#ifndef full_rpg_text_based_storyboard_h
#define full_rpg_text_based_storyboard_h

#include <strings.h>
#include "character.h"

using namespace std;

class storyboard 
{
public:
    
    static void cutscene(int segment);
    
};


#endif


storyboard.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include "storyboard.h"

using namespace std;

void storyboard::cutscene(int segment)
{

    if (segment == 1) 
    {
        cout << "??? wakes up in a grassy field..." << endl;
        cout << "and sees three blurred figures" <<endl;
        sleep(1);
        cout << "'hey, what's your name?' the tallest one of them asks.";
        string temp;
        cin >> temp;
        character::create_user(temp, 100, 100, 1000);
        cout << "hey, " << user.name << endl;
    }
}
character user; It is a global variable in character.h. It will be declared in following files: character.cpp (includes character.h), storyboard.cpp (includes storyboard.h which includes character.h) and main.cpp (through storyboard.h)
where should I put it so it won't be declared more than once?

-ASCII14
Topic archived. No new replies allowed.