views:

705

answers:

19

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?

+16  A: 

Pointer 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.

driis
And more importantly, use classes to do new and delete for you.
GMan
Or better yet, knowing why you should avoid using new / delete in favor of RAII types
JaredPar
Remembering of course that using classes to do new/delete for you, and using RAII types in place of new/delete only make sense in the C++ world. As is said elsewhere, C and C++ are *not* the same.
Graham
Pointer arithmetics are pretty straightforward, and not that often used. I don't think that's the most important thing for the OP to know about.
jalf
A: 

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.

JonH
+2  A: 

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.

Eric Petroelje
+5  A: 

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.

Greg D
+16  A: 
luke
Wow, your company lets you use Boost? We get smacked down on it every time we try.
Greg D
Sorry to hear that, it's pretty handy.
luke
Why a company wouldn't let their developers use a free library to save them time baffles me :/
GMan
@GMain: It's baffled me for years too. I think it's a toxic case of NIH. Ironically, the NIH paranoia doesn't spread to the use of less reputable sources of third-party code. I can't tell you how many times I've replaced massive swaths of code copied from CodeProject with simple 1-2 line functions.
Greg D
A: 

Other than pointer arithmetic as pointed out, memory management is a huge deal.

Otávio Décio
A: 

First is memory management, including pointer...

And learn to code some thing cross-platform ( that's what I like ;) )

Fu4ny
+1  A: 

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.

Carl Norum
+2  A: 

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.

Foxfire
+1  A: 

Pointers hurt, handle them carefully!

kloucks
I love my pointers. even if they are a little pointy. ;)
John Gietzen
+10  A: 

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.

Jerry Coffin
The problem is that manual memory management is used and must be learned and understood. Good advice though.
kenny
Agree that STL and the starnard lib is substantial, but I do think that there are situations where manual memory management is essential. Especially if you have 1) many small different sized objects to create 2) want to have better debugging or statistics capabilities 3) The performance of the standard implementation is not fast enough. 4) The standard implementation is not deterministic in realtime applications. Memory pools can help here a lot! But I agree with you that you should not START with this topic. Other topics are more substantial.
schoetbi
@schoetbi: I didn't mean to say nobody should ever learn about or use manual memory management in C++. The question was what was needed to be considered for a job doing C++. On a prioritized list, manual memory management shouldn't be the first item, and if it's on the first page, it should probably be somewhere close to the bottom.
Jerry Coffin
@Jerry: Agree here, at the "bottom" you need more of this management.
schoetbi
+1  A: 

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.

Nemanja Trifunovic
+3  A: 

I want my pointers to pointers to pointers baby!

Steve
A: 

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!

A: 

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.

David Thornley
A: 

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++.

Paul Nathan
A: 

Hit yourself in the head until your ability to feel pain dies.

quillbreaker
A: 

In my opinion there are several things you need to learn/refresh:

  1. Pointers (classic, and smart pointers), new / delete all that stuff
  2. 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.
  3. Templates. I know that most people think that templates are quite easy, but if you dig a little deeper ;)
  4. 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.

MaciekTalaska
A: 

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.

Paul Arnold