6

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?

Arron S
  • 5,395
  • 6
  • 47
  • 57
  • 16
    You should find out if the position is a C position, or a C++ position. These require very different skills. – Chris Jester-Young Oct 12 '09 at 17:25
  • Depressingly, at the level of sifting through ads there are still many posts listed as exactly "C/C++". Possibly because recruiters use Google, which ignores punctuation anyway (I'm kidding, actually Google does understand "C++", possibly as a special case introduced by fed-up Googlers). I take C/C++ to mean "both" until proven otherwise, but clearly in almost all organisations the emphasis will be overwhelmingly on one or the other. – Steve Jessop Oct 12 '09 at 17:48
  • Personally, I found it a pain to deal with the 10 different string implementations. – Yuriy Faktorovich Oct 12 '09 at 17:49
  • [Tips and tricks - Hidden features of C#](http://stackoverflow.com/questions/9033/hidden-features-of-c) – Sen Jacob Jun 04 '13 at 04:36
  • Learn to user RAII, not just for memory, but for resources. – Adrian McCarthy Jul 19 '13 at 19:39

19 Answers19

17

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
  • 151,614
  • 43
  • 262
  • 332
  • 10
    And more importantly, use classes to do new and delete for you. – GManNickG Oct 12 '09 at 17:37
  • 8
    Or better yet, knowing why you should avoid using new / delete in favor of RAII types – JaredPar Oct 12 '09 at 18:14
  • 1
    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 Oct 12 '09 at 21:27
  • 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 Oct 13 '09 at 11:49
15
luke
  • 32,714
  • 7
  • 56
  • 80
  • 1
    Wow, your company lets you use Boost? We get smacked down on it every time we try. – Greg D Oct 12 '09 at 17:25
  • 2
    Sorry to hear that, it's pretty handy. – luke Oct 12 '09 at 17:26
  • Why a company wouldn't let their developers use a free library to save them time baffles me :/ – GManNickG Oct 12 '09 at 17:38
  • @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 Oct 12 '09 at 17:47
9

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
  • 437,173
  • 71
  • 570
  • 1,035
  • 1
    The problem is that manual memory management is used and must be learned and understood. Good advice though. – kenny Oct 12 '09 at 19:42
  • 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 Sep 07 '10 at 18:14
  • @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 Sep 07 '10 at 18:40
  • Agree here, at the "bottom" you need more of this management. – schoetbi Sep 08 '10 at 05:49
6

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
  • 41,086
  • 13
  • 81
  • 115
3

I want my pointers to pointers to pointers baby!

Steve
  • 2,103
  • 4
  • 22
  • 31
2

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
  • 5,513
  • 18
  • 29
1

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
  • 57,359
  • 8
  • 118
  • 174
1

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
  • 201,810
  • 27
  • 390
  • 454
1

Pointers hurt, handle them carefully!

kloucks
  • 1,559
  • 9
  • 11
1

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
  • 23,597
  • 3
  • 46
  • 84
0

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
  • 31,157
  • 11
  • 79
  • 138
0

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

Otávio Décio
  • 70,467
  • 17
  • 156
  • 220
0

First is memory management, including pointer...

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

ntcong
  • 812
  • 2
  • 7
  • 15
0

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!

0

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
  • 54,186
  • 8
  • 87
  • 153
0

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
  • 37,919
  • 28
  • 110
  • 204
0

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

quillbreaker
  • 5,903
  • 3
  • 25
  • 46
0

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.

Maciek Talaska
  • 1,588
  • 1
  • 12
  • 21
0

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
  • 419
  • 3
  • 7