Well I been studying like a rabid dog foaming at the mouth since I have a higher level language under my belt and my initial failiure at c++ as a first language. Anyway getting near the end of my first little tutorial and have a few more questions.

1. I have hear many opinions that C is not necessary or even prefered if you are going the route of C++. That being said I've been starting to become curious about strings and it seems that some C knowledge may be needed or prefered when it comes to strings. Would this be correct to assume?

2. Another question about strings... I have used sstream in a few small programs in the tutorial and researched it a bit. From what I'm gathering it is a class that creates an object of type string? But it is also refered to as a stream buffer which in my mind tells me it is somewhat of an array stored in memory which makes sence in a way. So before I start rambling in to many circles on this one. Do I need to concern myself with how sstream works inwardly or can I just learn it's funcionality and forget it? I would in either case be interested to know if it basically just allows you to create an array in memory and preform special funcions on that array.

Thanks so much and hopefully most of my future posts in this forum will come with associated code as I plan to start up a few small projects after completing the tutorial I'm working on.

Recommended Answers

All 5 Replies

1. I'll skip 1 except to say the totally meaningless "it depends". Hopefully someone else will jump in with something smarter.

2. >> Do I need to concern myself with how sstream works inwardly or can I just learn it's funcionality and forget it?

Learn the functionality first, then worry about how it works. I wouldn't go so far as to not concern yourself at all, but I'd lean towards learning how to use it. Some things are a black box and that's OK. Some things can't be mastered unless you know the inner workings. But I think if you try to learn about how strings and stringstreams work under the hood, it could easily get quite overwhelming for a noob.

I have hear many opinions that C is not necessary or even prefered if you are going the route of C++.

If you want to learn C++, learning C first is silly. If you want to be a well rounded programmer, learning C at some point is a good idea. Why? Because C and C++ have different programming styles and idioms. Good C is very likely to be extremely poor C++, so you won't be encouraged to learn the lower level aspects of programming when using C++. With C you have no choice, and being pushed into a fundamentally different way of thinking is enlightening.

That being said I've been starting to become curious about strings and it seems that some C knowledge may be needed or prefered when it comes to strings. Would this be correct to assume?

If you're interested in the underlying aspects of strings, lower level knowledge is helpful, but not necessarily C knowledge. In C++ you're encouraged to use the std::string class instead of char arrays, and even vanilla arrays themselves are falling by the wayside with std::vector and tr1::array (soon to be std::array with C++0x).

However, when learning about the standard library implementations and base libraries in general, you'd be better served with a strong foundation in computer science than experience with any single low/mid level language.

Do I need to concern myself with how sstream works inwardly or can I just learn it's funcionality and forget it?

Learning the functionality goes a long way toward understanding the underlying implementation and it's also more practical. iostreams in general are a very complex part of the standard library, but I won't lie and say that knowing how the back end works doesn't help. For example, a lot of beginners have trouble with things like leaving a newline in an input stream and flushing input streams. Recognizing that streams are inherently sequential and formatted input is really an in-memory character conversion are both surprisingly helpful in avoiding such problems.

I would in either case be interested to know if it basically just allows you to create an array in memory and preform special funcions on that array.

I'm not sure I see the connection. Can you elaborate?

commented: can't add anything to that! +11
commented: very informative thank you +2

I'm not sure I see the connection. Can you elaborate?

I guess what I was gettin at here was if sstream creates an object of a string in memory which would most likely be an array then would I be correct to think of it as...

"s" "t" "r" "i" "n" "g"
0 1 2 3 4 5

Or something similar to that.

It would probably be better to think of the stream as a queue than a string with indices. That way you have the correct perspective of only being able to process it sequentially, whereas strings allow random access.

Oh ok that's what I kinda thought of when I thought of stream, but when I thought of memory that's why array seemed locial to. Thanks alot for clearin it up Narue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.