I have a little bit of experience in c/c++ from college but have not worked in it for years. What sorts of things do I need to know to even be considered for a c/c++ job position?
views:
705answers:
19Pointer arithmetic would probably be on the top of the list. Also, a good understanding of memory management in the unmanaged world would help - such as remembering to delete what you construct with new.
Syntax can always be picked up at any time even after obtaining a position. The important thing to take into account is how to tackle a problem. What algorithm will work better for a specific issue. How much object oriented programming do you remember. How well are you with pointers and pointer arithmaetic.
I think forgetting some syntax is ok, the most important think to tackle is how to solve problems.
If you already know C#, the biggest things you'll probably want to brush up on would be memory management, pointers/references and (for C++) the STL.
From a practical standpoint, I'd say that priority number one is you give yourself a workout in manual management of object lifetimes again. The big timesaver in C# and the .Net world is the magic that the garbage collector provides. One still needs to manage memory in the managed world, but it's a much simpler task and isn't necessarily tied to maintaining a mental model of object ownership and lifetimes.
In C/C++, you're re-entering the world of hairy memory management, lifetime management, and object ownership.
- memory management (pointers, memory allocation, references)
- The Standard Template Library
- Boost
Other than pointer arithmetic as pointed out, memory management is a huge deal.
First is memory management, including pointer...
And learn to code some thing cross-platform ( that's what I like ;) )
I think it depends on what kind of C/C++ job position you mean. For embedded work, you'd better be great with pointers and understand the 'volatile' keyword. For higher-level stuff (particularly in C++) you probably want to learn some of the popular libraries going around (STL, boost, etc.). For most C programming, being comfortable with POSIX is going to be important.
Number one with a bullet, I think - memory management. That means malloc/free, new/delete, all that other weird C++ stuff (copy constructors), and pointers in general.
It depends on WHAT you have experience in. Hardly nobody has experience in everything in and around C#. One thing might be memory management. On the other hand if you have a lot of experience with C# unsafe code you already know nearly everything there is. Other thing might be platform/com stuff. Same thing if you already did a lot of interop programing. To be effectively you probably just need some practice. Also programing style is often very different.
I have to disagree with a lot of the advice you've received. You should not concentrate on manual memory management. Manual memory management was/is difficult to avoid in C. Most C++ code, however, has little need to use manual memory management at all. Manual memory management is heavily overused in a great deal of code, leading to many problems that would have been easy to avoid.
The first and most important thing to study is the standard library. It's substantially different from .NET (to put it mildly). My immediate advice would be to pick up a copy of Accelerated C++, and work through it. It's designed for people in exactly your position (i.e. learning C++, but already have experience with at least one other language), and for that situation I'm pretty sure there's no better book available.
Edit: (mostly in respond to Kenny's comment) -- it's true that especially if you're maintaining existing code, there's a pretty good chance that you'll be stuck with learning about all manner of unpleasantness any sane person would probably rather avoid. Likewise, depending on the team you join, you might be stuck with ugliness even in new code. Unfortunately, without a fair amount of background and experience with the language, it might not be at all apparent what to look for.
The most important advice I can think of: don't try applying C# code practices with C++. Avoid creating objects with new, use free functions, forget about reflection... just treat it as a very different language and try to learn it from scratch.
As stated by others, pointers and memory management should be your priorities. You definitely need to understand pointers. That is the most difficult concept in C/C++ programming. It seems a lot of people just can't get their minds around pointers and until you do, you will never be a C or C++ programmer.
Yes, there are great libraries that handle memory management for you but, because there is a lot of code that has been developed without those libraries, you are probably going to be dealing with some mallocs/frees or new/delete's. Unless of course, you have the luxury of walking into a job where you are only writing new code and you can "do things right" from the start. If you find that company, let me know. I'd like to submit my resume too!
First thing to learn: C and C++ are two distinct languages. Even in cases where code is valid in both, it's very often not good code in both (sometimes in neither).
Pick one of the languages and learn it. Then learn the other if you like. C++ is more complicated, but you'll already be familiar with a lot of it. C is less complicated, but does things differently from C#. With C, you're programming at a lower level, closer to the machine, which may be desirable or undesirable.
I would tackle memory management from a different perspective: read a book on copmuter architecture to get a sense of what memory really is, then brush up on your assembler. That will get you the nitty-gritty of what's going on under the hood(which is very thin in C). C++ helps move you up a bit, but assembler still lurks under the hood.
Practically, C++ is C with classes & templates. That's a bit of a simplification and is technically incorrect, but gets you 80% of the way there.
Then...buy:
The C Programming Language by Kernighan and Ritchie. That's the C book.
The C++ Programming Language, by Strousoup; that's the standard C++ reference.
Depending on how deep and hardcore you get, you may want to get the Effective C++ books and Accelerated C++.
In my opinion there are several things you need to learn/refresh:
- Pointers (classic, and smart pointers), new / delete all that stuff
- STL. Couple of years ago there were a lot of people, who treated C++ as a "C with classes". And it is of course not the point. Knowledge of STL will not only save you a lot of time, but also give you some good understanding how some things should be done in C++ (in your code) just to make them easy to use for other developers.
- Templates. I know that most people think that templates are quite easy, but if you dig a little deeper ;)
- Boost. Just as STL there are a lot of interesting things in Boost that you may use in your day to day job.
I think those are the most important ones.
If you are planning on working on the Windows Platform you could do well to pick up a copy of Advanced Windows Debugging which contains a great introduction to the kinds of debugging tools that are available to Windows developers.