unexpected class?

This is a discussion on unexpected class? within the C++ Programming forums, part of the General Programming Boards category; I'm killing time before class and I've hit a problem with my console rpg. I declare a class player_t in ...

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    unexpected class?

    I'm killing time before class and I've hit a problem with my console rpg. I declare a class player_t in file player.h:
    Code:
    #ifndef PLAYER_H
    #define PLAYER_H
    
    #include "map.h"
    
    class player_t {
    private:
      int x, y, hp, *numitems;
    public:
      player_t(map_t&);
      ~player_t();
    };
    
    #endif
    and I get these weird errors:
    h:\rpg\rpg\player.h(10) : error C2629: unexpected 'class player_t ('
    h:\rpg\rpg\player.h(10) : error C2238: unexpected token(s) preceding ';'
    I've gone through the code and I'm not missing a } or anything obvious, does anyone know what's wrong here or how I can fix it?
    Illusion and reality become impartiality and confidence.

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    A problem in map.h perhaps?

  3. #3
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Since map_t only shows up as a reference, you can replace the include with a forward declaration:
    Code:
    class map_t;
    
    class player_t { // etc };
    At least might help isolate if the problem is with map.h or player.h
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Default class template problem
    By Elysia in forum C++ Programming
    Replies: 5
    Last Post: 07-11-2008, 08:44 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  4. Abstract class problem
    By VanJay011379 in forum C++ Programming
    Replies: 9
    Last Post: 07-31-2002, 01:30 PM
  5. unexpected 'class Window (' ??? i dont understand the error
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 10:12 AM

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