Class Constructor errors

This is a discussion on Class Constructor errors within the C++ Programming forums, part of the General Programming Boards category; i am having trouble getting this silly thing to work. i am getting an error that says "return type specification ...

  1. #1
    Unregistered
    Guest

    Class Constructor errors

    i am having trouble getting this silly thing to work.

    i am getting an error that says "return type specification for constructor invalid"

    i am using dev-c++ to compile it

    it is the 24th line down, with the //THIS LINE HAS THE ERROR


    // Player class declaration
    class Player
    {
    private:
    char playerName[15];
    char sex; // Male or Female (M/F)
    short int health;
    short int strength;
    short int agility;
    short int magic;
    short int gold;
    public:
    Player(int str, int agi); // constructor
    ~Player(); // destructor
    void reportStats(); // shows stats
    void attack(); // kill monster
    void move(); // move N, E, S, or W (do i need parameters?)
    void rest();
    void getPlayerInfo(); // name, sex
    }

    // constructor definition
    Player::Player(int str, int agi) // THIS LINE HAS THE ERROR
    {
    strength = str;
    agility = agi;
    health = 10;
    magic = 20;
    gold = 20;
    }

    Player::~Player() // destructor (does nothing for now)
    {
    }

  2. #2
    Unregistered
    Guest

    the error

    found the error. i forgot to put a ; after the } =P

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with FIFO QUEUE
    By jackfraust in forum C++ Programming
    Replies: 23
    Last Post: 04-03-2009, 09:17 AM
  2. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  3. Defining derivated class problem
    By mikahell in forum C++ Programming
    Replies: 9
    Last Post: 08-22-2007, 03:46 PM
  4. matrix class
    By shuo in forum C++ Programming
    Replies: 2
    Last Post: 07-13-2007, 02:03 AM
  5. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 02:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21