Why doesn't this work? (only like 20 lines of code)

Why doesn't this work? I get a error on the first line of the main function when I try to turn my class into a object called do



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
  #include <iostream>
#include <string>
using namespace std;

class DarylsClass{

public:
    void setName(string x){
        name = x;
    }
    string getName(){
        return name;
    }

private:
    string name;

};




int main()
{
    DarylsClass do;
    do.setName ("This is Daryl");
    cout << do.getName();
    return 0;
}
@Helloworldv2

do
, is a reserved command word in c++, used in a do/while loop.
ohhhhh thanks, i fixed it by renaming it. I just picked the letters "do" meaning daryl's object
closed account (E0p9LyTq)
C ++ keywords - cppreference.com
http://en.cppreference.com/w/cpp/keyword
Topic archived. No new replies allowed.