String (newb)

Hi all,

At this tutorial site(http://cplus.about.com/library/weekly/aa051202b.htm) it says that to create a string all i have to do is

1) #include <string>

then
2) string thisIsAString

and that's it.

but it doesn't work! i'm sure it's something stupid that i'm doing
i use MS vis. c++ 6.0

thx nick
nick81Asked:
Who is Participating?
 
monkesdbConnect With a Mentor Commented:
Sys_Frog

you still need to state which namespace it's in !!!
0
 
Sys_ProgCommented:
That's what u need
What problem r u facing

POst ur code

Amit
0
 
monkesdbCommented:
#import <string>
using namespace std;

...

string myString;


OR

#import <string>

...

std::string myString;

!!!
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
Sys_ProgCommented:
Sample code

#include <iostream>
#include <string>

int main () {
       string str1 = "Hello" ;
       string str2 ( "World" ) ;
       string str3 = str1 + str2 ;
       cout << str1 ;
       cout << str2 ;
       cout << str3 ;
}

Amit
0
 
Sys_ProgCommented:
monkesdb,

VC++6.0 doesn't require it
But yep, others do require

Amit
0
 
nick81Author Commented:
I forgot the namespace, very stupid. thx everyone. monkesdb did mention it so i'll give him the points.
0
 
nick81Author Commented:
vc++ 6.0 doesn't require it? well it didn't work when i didn't use using namespace std;

nick
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.