Getting error for string identifier even though I'm including <string>

I am getting the error line 48.
Anyone know why?

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
 #include <iostream>
#include <string>


using namespace std;


#include <painting.h>


int main()
{

    painting colorSwatch("A Swatch", 1, 1);

    int redLevel = 85;
    int greenLevel = 168;
    int blueLevel = 255;

    //
    // Display redLevel, greenLevel, and blueLevel on the screen
    //

        cout
            << "Color levels:  red = " << redLevel
            << ", green = " << greenLevel
            << ", blue = " << blueLevel
            << endl;

    //
    // Set the color of the swatch
    //

        colorSwatch.getDot(0, 0).setRedLevel(redLevel);
        colorSwatch.getDot(0, 0).setGreenLevel(greenLevel);
        colorSwatch.getDot(0, 0).setBlueLevel(blueLevel);

    //
    // Show the swatch
    //

        colorSwatch.reveal();

    //
    // Pause so that the user can examine the swatch
    //

        string inputToBeIgnored;

        cout << "Enter any string to continue ...";
        cin >> inputToBeIgnored;

    //
    // Hide the swatch
    //

        colorSwatch.conceal();

    return 0;

    }
Last edited on
Works fine for me, can you copy-paste the error messages?
The whole thing is too long, but this might help.

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [dist/Debug/GNU-MacOSX/assign03osx] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 359ms)

I'm using netbeans, and it is also showing "Unresolved identifier" on line 48.
Try and post everything in your headerfile to the main body of your code, can't get it to compile with your header file code it seems.

Maybe try declaring your string at the top of main instead of in the middle of your program see if that does anything.
Last edited on
Topic archived. No new replies allowed.