More information about C++ for a job interview

Hello friends,

I’ve applied for a job interview and I will have a test about C++. I come from C# and know most of the stuff, but C++ has different things like “volatile” “friend”, etc etc. Different inheritance types …
I wonder where I can read more about them. I don’t have a problem googling about them. I just don’t know what I don’t know :smiley: Can someone point me out somewhere. I’m studying data structures right now. But I need more information on C++.

If you already know C# and know how to program, maybe you could try the “bible” of C++. “The C++ Programming Lenguage” by Bjarne Strousoup(the creator of c++ himself). That book might be the absolute densest thing ive seen in my life, but if you want to learn the “complicated” parts of c++ and what makes it unique, you should have a look at that book. Pretty much everything is on it. Another recommendation is the “Effective C++” series, but those are mostly for “style” and how to write better code, not to learn new stuff.

Hmm, I know what book. But it’s quite big to read until next wednesday haha. What question should I expect? I’m applying for a internship. They said they gonna teach me the fundamentals of C++ and then will move on more hard stuff.

As far as I know, they could ask about Abstract Data Structures in C++, like “How to reverse a SingleLinked List?”


Oh a typo… I meant that* book :smiley:

It depends on the job you’re applying for.

Another stupid question could be “Difference between a struct and a class in C++”

Okay I got an email of what should I expect: “Basic operations on arrays and strings”. I suppose something like reversing lists, finding max/min values in them etc?

You’re fortunate. It’s very easy.

Well if you are familiar with pointers, you should know that the identifier of an array of X elementes is just a pointer to the first element of this array.

Let’s pretend on your machine an int takes 4 bytes. Making an array of 2 ints ( int p[2] ) will look like this


The first 4 magenta blocks is the first integer, the other 4 are the second integer.
Our pointer P (which is the name of the array) is pointing to the first integer (first block) of the array.

*cout << p will print the first integer.

There’s a fancy thing called pointer arithmetic.

*cout << (p+1) this will print the second integer

Notice that we are not modifying the pointer and we can’t because don’t forget that this is a pointer belonging to an array, it’s no “free-to-use” like normal plain pointers.

Notice also the +1. That would have been the same thing writing cout << p[1]

This is a **very very very **short example about pointer arithmetic.


Operations on strings I don’t know if he speaks about STL strings (C++) or plain strings like char] strings and char* strings (C-like strings)

Either way, remember the first case you are making a size-fixed array of characters (you should know the average lenght you need for your string since the beginning). It doesn’t include any particular operation like assignment operator

The second one is more flexible in terms of operations, but that is a constant string which cannot be modified.

Very very general even about this part, but there are a lot of tutorials online you can study from!

Thank you very much about that. Cleared out some stuff for me :). And I suppose I need to manually allocate memory for the pointer.

It depends where you want to allocate your objects. Stack or Heap.

In the case of the arrays:

int MyArray[5];

int MyArray = new int[5];*

Remember to also manually delete memory allocated on the heap!

int* VariableOnTheHeap = new int { 5 };
delete VariableOnTheHeap;

int* ArrayOnTheHeap = new int[2];
delete] ArrayOnTheHeap;