C++ Help - Can't use strings in method declaration

Discussion in 'General Off-Topic Chat' started by The Teej, Jul 27, 2008.

  1. The Teej
    OP

    The Teej Also known as The Tjalian

    Former Staff
    3
    Jun 27, 2004
    England
    Hey all, I have this in my header file:

    Code:
    void ObjectCreator(std::string sActorGroup_, std::string sActorName_, std::string sActorVariable_);
    Yes yes, it's all in the appropriate places etc, but I get this error:

    Error 1 error C2653: 'std' : is not a class or namespace name
    Error 2 error C2061: syntax error : identifier 'string'

    I've tried getting rid of std::, but that still doesn't make it work. Any ideas on how to make it work? I tried including in the header file, but then as soon as I go to execute that class (never mind the method) it immediately breaks at "strlen.asm", so I'm guessing that's not the right way to go [​IMG] Any ideas, anybody? I'm running out of ideas on how to fix this. I've researched and researched but found no fix.

    Thanks.
     
  2. dg10050

    dg10050 GBAtemp Regular

    Member
    2
    Jun 24, 2006
    United States
    I'm not a C++ programmer, so I'm not sure this'll work, but try declaring the strings as globals earlier in the code. Then just use the following to declare your method:
    Code:
    void ObjectCreator(sActorGroup_, sActorName_, sActorVariable_);
    EDIT: Now that I look at it, should there really be a semicolon there? Shouldn't that be followed by some code enclosed in {}? Like I said, I'm not a C++ programmer, so IDK. Also, what I said before shouldn't actually be necessary.
     
  3. Trippy

    Trippy GBAtemp Regular

    Member
    1
    Dec 6, 2006
    United States
    Did you use "using std::string" or maybe it was just "using namespace std"
     
  4. The Teej
    OP

    The Teej Also known as The Tjalian

    Former Staff
    3
    Jun 27, 2004
    England
    Tried both, neither works.

    Please remember guys, this is in the HEADER file, not the cpp file.
     
  5. CockroachMan

    CockroachMan Scribbling around GBATemp's kitchen.

    Member
    2
    Jan 14, 2006
    Brazil
    Brazil
    On your header file, are you using:

    CODE#include

    using namespace std;
    ??

    Also, once you put the "using namespace" thing you can take out the "std::" from the code.
     
  6. The Teej
    OP

    The Teej Also known as The Tjalian

    Former Staff
    3
    Jun 27, 2004
    England
    I've tried this, but it breaks at strlen.asm. Originally, I was using chars in the method, but I've found out I need to use strings instead.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice