Top 5 C++ Interview Questions to Test Your Programming Prowess

Sdílet
Vložit
  • čas přidán 22. 05. 2024
  • Are you gearing up for a C++ job interview? Whether you're a seasoned C++ developer or a recent graduate looking to land your first job, it's essential to be prepared for the technical questions that may come your way during the interview process. In this video, we've compiled a list of the top 5 C++ interview questions that are frequently asked by hiring managers and technical interviewers.
    Top 5 C++ Interview questions and Answers
    Take a look at the top 5 C++ interview questions you face on an interview and how to answer those questions in the best possible way
    Job Interview
    Interview Preparation
    C++ interview
    C++ Interview Questions
  • Věda a technologie

Komentáře • 22

  • @ivayloi736
    @ivayloi736 Před 4 lety +6

    I'll give this guy 6 of 10. Q1 + Q2 are quite stupid, you should never mess with the stack and heap in a way that was not intended. If you are not a compiler developer - end of discussion... Size of the structs matter even today in many cases, for example - keeping cache alignment, when working with GPUs. #ifdef #endif have a lot of usages. Include guards are not the best example, since most compilers have #pragma once which is faster. NULL is basically for C programming, while nullptr is for C++. NULL is still used in legacy code, low level WIN32 programming, and one should follow the general convention there.

  • @icecog
    @icecog Před 5 lety +4

    Q1. If the local variable is living in stack frame of another thread, the access of that memory piece is valid through a pointer from another thread until the threads are running. Although some lifetime management and synchronisation are needed.
    Q3: Size of the structs can be important regarding different communication protocols and their packets.

  • @samacumen
    @samacumen Před 6 lety

    Great job!

  • @Gargantupimp
    @Gargantupimp Před 5 lety

    Thanks man

  • @fatimanaeem3993
    @fatimanaeem3993 Před 5 lety +2

    He looks so much like benedict. :D

  • @JayAnAm
    @JayAnAm Před 4 lety +3

    Q3: So designing it like this makes more sense, right?
    struct TStruct
    {
    char a;
    char b;
    short c;
    int d;
    };

    • @kseniarogova630
      @kseniarogova630 Před 4 lety +1

      Yes.
      I'd recommend u to read smth about data structure alignment in C++. Actually, it's very cool to understand how architecture of computer processor manage all this work with memory and why on earth this padding happened.

  • @spicytuna08
    @spicytuna08 Před 6 lety +1

    #1, create another dummy function. this will most likely prove your point.

  • @prashantkulkarni2075
    @prashantkulkarni2075 Před 5 lety +1

    Awesome

  • @oj0024
    @oj0024 Před 6 lety

    Eazy

  • @petersouthwell5971
    @petersouthwell5971 Před 3 měsíci +1

    It took you forever to get to the point. These don't sound like C++ questions... They're too basic. This is like... Guy right out of college level...?
    Im sure your good man.. I just wanted more questions about the language and less about how pointers work.

    • @petersouthwell5971
      @petersouthwell5971 Před 3 měsíci

      I mean you didn't cover things like virutal inheritance how it works in multiple inheritance. The new Lambdas C++ supports. The mutex, critical section classes... Whats new in std template library stuff like that...
      You just sorta noodle noised on basic stack allocation during method calls. Is this really how C++ interviews are conducted? I expected more code, patterns and newer features and less explanation about boiler plate interactions of heap and stack.

  • @roarraizzer9529
    @roarraizzer9529 Před 5 lety +2

    useful info: keyword new - calls the constructor
    keyword delete - calls the destructor.
    Hit like, if you didn't know 'bout this.

  • @maxooder
    @maxooder Před 5 lety

    call to foo(NULL) is ambiguous in most compilers and leads to a compilation error, it's bad example imo

    • @greatbullet7372
      @greatbullet7372 Před 5 lety +1

      what the hell are you talking about NULL is defined as 0 and for compatibilityreasons whidely used instead of nullptr. WTF ^^

    • @maxooder
      @maxooder Před 4 lety

      ​@@greatbullet7372 run cpp.sh/8zqjo, go back to school and do not post your stupid comments

  • @VivekYadav-ds8oz
    @VivekYadav-ds8oz Před 5 lety +3

    Isn't that beginner level..?

  • @dmitponv4958
    @dmitponv4958 Před 6 lety +2

    #1. you can do this, if you use shared_ptrs

    • @michaelthompson7217
      @michaelthompson7217 Před 5 lety +1

      Nice point, but for those reading this is somewhat of a “clever” solution (not in a good way) and I would never say this in an interview. It’s frankly a kludge.
      Any programmer who jumps to this as a potential solution would immediately set off red flags for me. Code would be totally unmanageable, hard to read, dangerously subject to memory leaks.
      If you need dynamic memory, use the heap. If you need to pass values down function calls by reference, you should be passing by reference. If you need static memory, allocate it statically. Don’t do this as a workaround for any of those three.