Thread: unexpected class?

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

    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:
    #ifndef PLAYER_H
    #define PLAYER_H
    #include "map.h"
    class player_t {
      int x, y, hp, *numitems;
    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
    A problem in map.h perhaps?

  3. #3
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Since map_t only shows up as a reference, you can replace the include with a forward declaration:
    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