Issue with a program on Classes

Hey everybody, I am very much a beginner of C++ and I have been working through some problems on Dev-C++ from a book. One of the exercises is to write a program about classes, using the example of humans.

This is what I have written so far:

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

class Human
{
      private:
              string Name;
              int Age;
              
      public:
             void SetName(string HumansName)
             {
                  Name = HumansName;
                  }
             
             void SetAge(int HumansAge)
             {
                  Age = HumansAge;
                  }
                  
             void IntroduceSelf()
             {
                  cout << "I am " << Name << " and I am " << Age << " years old." << endl;
                  }            
}
                  
int main ()
{
    Human FirstMan;
    FirstMan.SetName("Adam");
    FirstMan.SetAge(30);
    
    Human FirstWoman;
    FirstWoman.SetName("Eve");
    FirstWoman.SetAge(31);
    
    FirstMan.IntroduceSelf();
    FirstWoman.IntroduceSelf();
    cin.get();
}


After running, my compiler gives me an error message at line 29 (the "{" after the "int main ()" line) saying:

"new types may not be defined in a return type"
"extraneous 'int' ignored"
"'main' must return 'int".

(Also, I'm fully aware that finishing the program with "cin.get()" is bad practice over "return 0", only my interpreter vanishes immediately as soon as the program has been carried out otherwise.)


Could anybody please give me any hints as to how to solve this?

Many thanks,
Jimbob1192
a class in closed like this:

class human{




};

-with a semi-colon at the end.
You have to end the class with ;.
Wonderful! Thanks guys!
Topic archived. No new replies allowed.