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

    Former Staff The Teej Also known as The Tjalian

    Joined:
    Jun 27, 2004
    Messages:
    4,210
    Location:
    England
    Country:
    United Kingdom
    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

    Member dg10050 GBAtemp Regular

    Joined:
    Jun 24, 2006
    Messages:
    188
    Country:
    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

    Member Trippy GBAtemp Regular

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

    Former Staff The Teej Also known as The Tjalian

    Joined:
    Jun 27, 2004
    Messages:
    4,210
    Location:
    England
    Country:
    United Kingdom
    Tried both, neither works.

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

    Member CockroachMan Scribbling around GBATemp's kitchen.

    Joined:
    Jan 14, 2006
    Messages:
    3,889
    Location:
    Brazil
    Country:
    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

    Former Staff The Teej Also known as The Tjalian

    Joined:
    Jun 27, 2004
    Messages:
    4,210
    Location:
    England
    Country:
    United Kingdom
    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.
     

Share This Page