Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

help with text-based RPG!

[b][red]This message was edited by the markian84 at 2002-3-22 13:2:30[/red][/b][hr]

I'm working on a pretty basic text RPG and I need help . . . I have a class called character which (oddly enough) is the class for my characters. Is it possible to declare global instances of this class? How do I do that? I really don't want to have to pass eight different characters to every function. When I try and declare global instances (or even objects in a struct) I get errors like this:

c:alderstonmain.cpp(6) : error C2059: syntax error : 'PCH creation point'
c:alderstonmain.cpp(7) : error C2143: syntax error : missing ';' before '{'
c:alderstonmain.cpp(8) : error C2143: syntax error : missing ';' before 'PCH creation point'
c:alderstonmain.cpp(9) : error C2143: syntax error : missing ';' before 'PCH creation point'

what do I do? any help is greatly appreciated.

Comments

  • ScarecrowScarecrow Member Posts: 14
    : [b][red]This message was edited by the markian84 at 2002-3-22 13:2:30[/red][/b][hr]
    :
    : I'm working on a pretty basic text RPG and I need help . . . I have a class called character which (oddly enough) is the class for my characters. Is it possible to declare global instances of this class? How do I do that? I really don't want to have to pass eight different characters to every function. When I try and declare global instances (or even objects in a struct) I get errors like this:
    :
    : c:alderstonmain.cpp(6) : error C2059: syntax error : 'PCH creation point'
    : c:alderstonmain.cpp(7) : error C2143: syntax error : missing ';' before '{'
    : c:alderstonmain.cpp(8) : error C2143: syntax error : missing ';' before 'PCH creation point'
    : c:alderstonmain.cpp(9) : error C2143: syntax error : missing ';' before 'PCH creation point'
    :
    : what do I do? any help is greatly appreciated.
    :

    That's strange. I didn't have any problems declaring global instances of a class. By the way, am I to understand that PCH is the global instance of a class? If so, did you forget to put a ';' after the '}', or somewhere else in the class? Which compiler are you using?
  • UltraklonUltraklon Member Posts: 2
    why don't you post a little bit of the code for us to see it, remember that u can declare the global class like this:

    class TOMTOM{
    .
    .
    .
    } tomtomInstance;


    but don't forget the final ; !!!!!!!


  • OpLeXiUmOpLeXiUm Member Posts: 18
    : : [b][red]This message was edited by the markian84 at 2002-3-22 13:2:30[/red][/b][hr]
    : :
    : : I'm working on a pretty basic text RPG and I need help . . . I have a class called character which (oddly enough) is the class for my characters. Is it possible to declare global instances of this class? How do I do that? I really don't want to have to pass eight different characters to every function. When I try and declare global instances (or even objects in a struct) I get errors like this:
    : :
    : : c:alderstonmain.cpp(6) : error C2059: syntax error : 'PCH creation point'
    : : c:alderstonmain.cpp(7) : error C2143: syntax error : missing ';' before '{'
    : : c:alderstonmain.cpp(8) : error C2143: syntax error : missing ';' before 'PCH creation point'
    : : c:alderstonmain.cpp(9) : error C2143: syntax error : missing ';' before 'PCH creation point'
    : :
    : : what do I do? any help is greatly appreciated.
    : :
    :
    : That's strange. I didn't have any problems declaring global instances of a class. By the way, am I to understand that PCH is the global instance of a class? If so, did you forget to put a ';' after the '}', or somewhere else in the class? Which compiler are you using?
    :
    Hmm... That's odd I have never had any trouble declaring a global instance. why don't you post the section were you are declaring the global instance, then we could probably help you :)

  • CytCyt Member Posts: 557
    No why would you have to pass eight classes to a function?

    What you need is a class that encapsulates all players, or just a list that holds all the players.

    You can then pass this class&/list& to the functions that need it (or even better, have this list be a member of your game class.)
Sign In or Register to comment.