C++ Errors

I'm a newbie to C++ and I can't seem to understand some of the errors I'm getting.

What's really pissing me off is that I'm essentially writing the same program as another guy for practice. His don't get errors... here are the errors I am getting...

Multiple Definition of 'fcomplete'
First defined here

Then it repeats that with another complete function.

Please help me to understand what is going on.

Here is the source file in with the errors.

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
// Cross-roads

#include "Library.h"

bool Crossroads()

{
    int choice = 0;

    while (choice != 10)

    {

        cout << "You stand at a crossroads. There are several paths going off in many directions.\n\n";
        cout << "Behind you is a small market town full of shops \nand bustling with people.\n\n";

        // Player chooses his/her location

        cout << "Which path do you choose?\n";
        cout << "1: Town.\n";
        cout << "2: Summoning Portal.\n";

        if (!dcomplete)
            cout << "3: Desert Road (QUEST)\n";

        if (dcomplete && !fcomplete)
            cout << "4: Forest Road (QUEST)\n";

        if (fcomplete && !scomplete)
            cout << "5: Swamp Road (QUEST)\n";

        if (scomplete && !gcomplete)
            cout << "6: Graveyard Road (QUEST)\n";

        if (gcomplete && !ccomplete)
            cout << "7: Castle Road (QUEST)";

        cout << "10: Exit Game.";
        cout << ">";
        cin >> choice;
	}


    return true;
}

closed account (3pj6b7Xj)
Crossroads() is a function with its own scope, I don't see it being global and it does not take any arguments.

the int variable choice exists within the scope of crossroads() but dcomplete, fcomplete, scomplete, gcomplete & ccomplete dot not exist at all within the scope of crossroads() for you to check these variables, they must exist.

I see your function also returns a value of true which is either 1 or 0, choice accepts 10 variables of type int...here in lies your BIG MISTAKE, I guess these options only come up if the user has not complete these quests the problem is, these variables don't exists within the scope of crossroads()!

the "Multiple Definition of 'fcomplete'
First defined here" is a classic visual studio compiler error, does not even tell you what the problem is so you are clueless, its really trying to tell you that those variables do not exist.

You need to find a way to bring them into scope.....either global (bad idea), passing them by reference to the function or passing them by arguments.
Topic archived. No new replies allowed.