I'm an intermediate-level programmer and I've been writing the code for several years in PHP, later C#. N开发者_如何学Goow I want to learn some C++ through reading some short(let's say up to 2000 lines) well-written non-gui program sources. Have you got any ideas where so find something like that? I'd prefer some kind of networking tools... I just downloaded netcat but it's 1) written in C 2) too complicated for me
Thanks
I'd recommend Effective C++ #3 by Scott Meyers - it's a pretty cheap textbook, and it starts with some semi-advanced topics (at least with regard to design).
The reason I think it would be good for you is that I came from a C# background primarily, and I know that while you'll be decent with object oriented design (like I was), you'll probably get hit by a lot of the gotchas in C++ still.
The book does a very good job of showing you some intermediate level examples using arrays, pointer tricks, and newer STL/TR1 components. It'll teach you all the finnicky const correctness rules, and it'll basically cover all the areas of confusion for you.
It's not a complete program, but I don't think you'll learn anything from a complete program. People tend to do things wrong (even professionals) or according to their own whims. Something like this will show you enough code to get you stably on your legs, and will, more importantly, teach you why the code is right and what the alternatives are. This will help you remember it vividly :)
Pick up a book first.
I would look for small, toy problems like you would find for:
- Project Euler
- Programming competition websites
- Language shootouts
- Interview questions
Language shootouts are especially good because you are coming from another language, because you can see similar concepts translated. They will be abusively optimized and may not follow the same algorithms though.
Most of all, just start coding.
After you're done learning the basics of C++, really delving into the STL and the Boost libraries were a fantastic way for me to pick up some of the really cool stuff that C++ allows you to do. There's a hidden language in C++ that is template metaprogramming that you can easily miss if you just skim the surface of C++.
精彩评论