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

The Teej

Also known as The Tjalian
OP
Former Staff
Joined
Jun 27, 2004
Messages
4,210
Trophies
0
Age
37
Location
England
Website
zeldapower.com
XP
653
Country
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
tongue.gif
Any ideas, anybody? I'm running out of ideas on how to fix this. I've researched and researched but found no fix.

Thanks.
 

dg10050

Well-Known Member
Member
Joined
Jun 24, 2006
Messages
188
Trophies
0
Website
Visit site
XP
117
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.
 

The Teej

Also known as The Tjalian
OP
Former Staff
Joined
Jun 27, 2004
Messages
4,210
Trophies
0
Age
37
Location
England
Website
zeldapower.com
XP
653
Country
dg10050 said:
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.

Yes, there should be a semi-colon there, as I'm declaring it in the header and not in the cpp file. Also, I tried moving it to the CPP file and declaring it globally, but this does not work either :/

QUOTE(tritonfx @ Jul 27 2008, 04:24 AM) Did you use "using std::string" or maybe it was just "using namespace std"

Tried both, neither works.

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

The Teej

Also known as The Tjalian
OP
Former Staff
Joined
Jun 27, 2004
Messages
4,210
Trophies
0
Age
37
Location
England
Website
zeldapower.com
XP
653
Country
CockroachMan said:
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.

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.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    @Veho, where's the poll at?
  • Julie_Pilgrim @ Julie_Pilgrim:
    they're giving the internet an open text box?
  • BigOnYa @ BigOnYa:
    I never played or own any of they devices, but I like small style, but with a somewhat grip
  • Julie_Pilgrim @ Julie_Pilgrim:
    oh man, that always goes great!
  • Julie_Pilgrim @ Julie_Pilgrim:
    im sure half the responses won't be literal racial slurs or "drop table" jokes
  • Veho @ Veho:
    Look, it's China. They know what it's like when you give a poll to half a billion trolls.
  • K3Nv2 @ K3Nv2:
    How much dollar do you think it is?
  • Veho @ Veho:
    ONE MILLION DOLLA
  • Veho @ Veho:
    I know the pricing of electronics nowadays isn't "how much it actually costs" but "how much we can get away with", but putting up a poll is just cynical.
  • K3Nv2 @ K3Nv2:
    Probably $150 someone said Anbernic said around the same price as rg556
  • Julie_Pilgrim @ Julie_Pilgrim:
    you know which game i wish they would rerelease
  • Julie_Pilgrim @ Julie_Pilgrim:
    sonic unleashed
  • K3Nv2 @ K3Nv2:
    Make it a happy meal toy
  • Julie_Pilgrim @ Julie_Pilgrim:
    that game's engine is really fucking intensive so it runs like literal shit on xbox 360 and ps3
  • Veho @ Veho:
    Nah I'm getting value creep again. I look at a $50 console "but for just a few more dollars you could get XYZ" and I end up considering the Steam Deck.
  • Julie_Pilgrim @ Julie_Pilgrim:
    like the lighting in that game was genuinely so good
  • Veho @ Veho:
    Not getting dragged into that again.
  • Julie_Pilgrim @ Julie_Pilgrim:
    i dont get why they didn't port the one game that ran the worst on consoles, to pc
  • Julie_Pilgrim @ Julie_Pilgrim:
    like you port everything to pc except the one game where it would make the most sense. why. what do you gain from this
  • Julie_Pilgrim @ Julie_Pilgrim:
    is sega just personally fucking with me? are they laughing while watching me through my kinect camera as i get up to restart my xbox for the third time because the game froze again
  • K3Nv2 @ K3Nv2:
    Buy handhelds from five below better quality
  • K3Nv2 @ K3Nv2:
    Valve probably going to do another refresh of the deck this fall with rog ally like specs tbh
  • Veho @ Veho:
    A smaller form factor would be nice too.
  • K3Nv2 @ K3Nv2:
    A shield portable 2 would be nice aye Nvidia
    K3Nv2 @ K3Nv2: A shield portable 2 would be nice aye Nvidia