What is this?

What is that Character(string newName);?

Is it a void? I have never seen that before, and when I put it into my compiler, it gets a error.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Character
    {
    public:
        string name;
        short health;
        short damage;
        short arrows;

        Character(string newName);

        void attack(Monster& target);
       
        void rangedAttack(Monster& target);
    };
It's a constructor. And you shouldn't get an error, that's all perfectly legal assuming all those classes are defined.

See the section on constructors/destructors:
http://cplusplus.com/doc/tutorial/classes/
Topic archived. No new replies allowed.