Ok so I now know how to do...

This is a discussion on Ok so I now know how to do... within the C++ Programming forums, part of the General Programming Boards category; The hello world and the tab like cout << "The sum of 2 + 2 is:\t" << 4 << endl;.........What ...

From what I've seen this is not a good book. It teaches bad habits (like C style strings and plain dynamic arrays). There are other books available that don't have that problem that I would probably look at first.

From what I've seen this is not a good book. It teaches bad habits (like C style strings and plain dynamic arrays). There are other books available that don't have that problem that I would probably look at first.

But if you're looking for a book that will keep you interested in programming, go with my suggestion.

It builds on C-Style strings to teach you how to develop a string class (not a bad example by any stretch of the imagination).

>> It builds on C-Style strings to teach you how to develop a string class (not a bad example by any stretch of the imagination).

Does it teach you to use the C++ string class for your string needs? If not, then it doesn't matter whether it uses C style strings for developing a string class, because the reader of the book will develop the bad habit of using C style strings instead of C++ strings.

>> plain dynamic arrays?
Bad:

Code:

int* dynamic_array = new int[count];

Good:

Code:

std::vector<int> dynamic_array(count);

>> But if you're looking for a book that will keep you interested in programming, go with my suggestion.

Perhaps. I can't speak to that part (it's pretty subjective anyway). However, I would rather learn proper habits from a more boring book if I was really interested in the language in the first place.

>>
Does it teach you to use the C++ string class for your string needs? If not, then it doesn't matter whether it uses C style strings for developing a string class, because the reader of the book will develop the bad habit of using C style strings instead of C++ strings.

Not at all. I never said the book was the only suggestion, it's just one of many. There's no reason to think they can't learn to use <cstring> instead...

I honestly can't say I wish I had learned PERFECT coding habits up-front, I would have been bored to tears. I first got into programming for game development (like many members here), and now I learn systems in college.

If I had to worry about the overhead of the most trivial programs, or if I only had the core C/C++ language when I was first learning, I probably would've given up.

And what's so wrong with C-Style strings? In OS development, C is much more commonly used, and therefore a lot of the syntactic sugars of C++ are non-existent. A real programmer needs to know how to adapt to a situation with whatever tools are given to them.

What if PCG33K has to rebuild parts of *nix server from source? Guess what? I can almost guarantee C++ strings won't be an option, and for that matter <vector>

I'm sorry guys. I don't mean to step on anyone's toes, I accept that this is a *C++* forum, and therefore the threads should revolve around *C++*.

IMO there is nothing wrong however with learning alternatives to the status quo. I agree, the implementation of std::string is a wonderful thing, and I too wouldn't use anything else in a C++ program where there was heavy usage of *strings*.

I would say, learn C++ first, before C or any procedural lang. I see less problem with people migrating from OOP to lower-level langs than vice versa.

One of the first books I ever read on C++ was the one I mentioned. At the same time, I was in my beginning programming classes. In those classes, we used std::string. So I didn't give much credit to the string class the author develops, accept for it taught me something about classes (which I feel is not a bad thing).

In the other thread CornedBee, you said:

And how do you know how we learned classes?

I'm glad to say that I didn't learn classes by having people on the internet make me "consider" brain-dead designs.

You're right I don't know how you learned classes, but I would venture to say most people don't LEARN classes by designing very useful ones. I can recall one example I learned that was something like:

Is this a *brain-dead* design as you put it? Almost certainly. But it was one of those *baby-step* designs that helped me learn something about the structure of a class. It's merits I'd say are equal to that of a "Hello World!" program, not particularly useful, except as a learning tool.

So I would say to the OP, learn the difference between C and C++ (when you see something like <stdio.h>, let that be a hint...) C++ strings are good for C++ but non-existant in C. And almost certainly at some point, you will come across something claiming to be C++ but is really C, and for that reason alone, it might not be a bad idea to know what it looks like.