Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / I'm having trouble remembering how to do this.

Author
Message
dwilson32
18
Years of Service
User Offline
Joined: 11th May 2005
Location:
Posted: 16th May 2005 13:40
Hi there. I am having trouble remembering how to access a class from an include within one of my classes. If you look at this code, the compiler does not see that there is a type of "string". As you can see, I have the string include up above. It works fine in the main code but I want that functionality to be in a class. Any assistance is much appreciated! Thanks!



Derik Wilson
dwilson32
18
Years of Service
User Offline
Joined: 11th May 2005
Location:
Posted: 16th May 2005 14:12
Sorry about the staggering of the code. It was nice and neatly indented when I pasted it.

Derik Wilson
Sephnroth
21
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 16th May 2005 16:06
#include <string>

using namespace std;

should fix it.

[07:16:59-pm] « Sephnroth » you were dreaming about lee...
[07:17:13-pm] « Mouse » stfu
[07:17:22-pm] « Mouse » he was hanging himself lol
dwilson32
18
Years of Service
User Offline
Joined: 11th May 2005
Location:
Posted: 16th May 2005 22:04
Thanks! It's always something stupid simple that I over-look. I tend to have the bad habit of over analyzing my code so I miss the most obvious problems. *kicking myself*

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th May 2005 22:45
You need to take care when using the 'using' command in C++. If that code sits in a header file and will itself be included into another file, then you should not put a 'using' at the top level.

If this is the case for your code, then you can put the 'using' command within the class.



*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins and source code http://www.matrix1.demon.co.uk
dwilson32
18
Years of Service
User Offline
Joined: 11th May 2005
Location:
Posted: 17th May 2005 07:28 Edited at: 17th May 2005 09:07
I'll put it in my class as you suggested. I had that line in my main code and when I moved the string logic to the sphere_dude class, I gave no thought to adding the line there as well, so my code stopped working. A silly little oversight. Thanks for your advice, all of you.

Login to post a reply

Server time is: 2024-04-19 19:55:46
Your offset time is: 2024-04-19 19:55:46