Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C - C++ Learning > Re: String from...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 9 of 15 Topic 4202 of 4262
Post > Topic >>

Re: String from C to C++

by Francis Glassborow <francis.glassborow@[EMAIL PROTECTED] > Jul 15, 2008 at 09:03 AM

lau.dvd@[EMAIL PROTECTED]
 wrote:
> I am starting to write C++ programs this summer, and I have background
> in C
> and Delphi (Object pascal).. When I wrote in C, strings are passed by
> char*,
> and I malloc/free all strings I need.. In Delphi, all strings are
> managed (off topic)...
> 
> I'm compiling using gcc 4.0.1 on Mac OS X,  but I am trying to stick
> to STL and none of the platform-specific facilities.
> 

Reading the rest of this thread makes me think you are fundamentally 
confused by C++ library types. In so far as is possible (and we have 
worked hard to ensure that there are few exceptions) a library type such 
as std::string behaves identically to a fundamental type such as int.

int main(){
   double d(0);
   d += 1;
   d += 2;
   d += 3;
   double d1(d);
   std::cout << d1 << std::endl;  // outputs 6
}

Should not cause you to wonder about how the values of d and finally d1 
are stored. Any storage management and conversions from literal values 
will be handled automatically.

And:

int main(){
   std::string s("help");
   s += " me";
   s += " please";
   std::string s1(s);
   std::cout << s1 << std::endl; // outputs 'help me please'
}

Should not cause you to wonder about how the values of s and finally s1 
are stored. Any storage management and conversions from literal values 
will be handled automatically.
 




 15 Posts in Topic:
String from C to C++
lau.dvd@[EMAIL PROTECTED]  2008-07-14 05:34:12 
Re: String from C to C++
"Daniel T." <  2008-07-14 09:05:20 
Re: String from C to C++
Bart van Ingen Schenau &l  2008-07-14 19:53:17 
Re: String from C to C++
lau.dvd@[EMAIL PROTECTED]  2008-07-14 19:40:10 
Re: String from C to C++
LR <lruss@[EMAIL PROTE  2008-07-15 01:49:45 
Re: String from C to C++
Bart van Ingen Schenau &l  2008-07-15 19:32:58 
Re: String from C to C++
Jerry Coffin <jcoffin@  2008-07-15 12:23:29 
Re: String from C to C++
Bart van Ingen Schenau &l  2008-07-16 17:43:55 
Re: String from C to C++
Francis Glassborow <fr  2008-07-15 09:03:38 
Re: String from C to C++
lau.dvd@[EMAIL PROTECTED]  2008-07-15 20:47:33 
Re: String from C to C++
Bart van Ingen Schenau &l  2008-07-16 17:53:34 
Re: String from C to C++
LR <lruss@[EMAIL PROTE  2008-07-16 13:32:02 
Re: String from C to C++
"Daniel T." <  2008-07-16 21:48:31 
Re: String from C to C++
lau.dvd@[EMAIL PROTECTED]  2008-07-17 19:09:56 
Re: String from C to C++
Bart van Ingen Schenau &l  2008-07-18 17:10:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 13:24:13 CDT 2008.