C++ Rapid-Fire: static, virtual, volatile & Pointers
- Answer the C++ keyword questions (static, virtual, pure virtual, volatile) in two or three spoken sentences each
- Explain pointer versus reference, smart pointers, struct versus class and shallow versus deep copy without notes
- Talk through C to C++ conversion and the C++17 features a 2026 Sunnyvale panel expected
- Read a short snippet aloud, say what it does and spot the bug, the older code-reading format
Most Lockheed Martin software interviews are one conversation with a hiring manager, and on a lot of teams part of it is a quick round of C++ questions. You won't write code in it. The manager asks, you answer in a sentence or three, and the next question comes. Twenty-two firsthand reports from 2020 to November 2026 describe it, and they cluster in embedded, Orlando, Fort Worth and Sunnyvale roles.
The 2026 reports set the pace. An embedded software engineer hired in November 2026 was asked about their resume and "around 10-12 conceptual C++ questions", with few behavioral ones. Two Orlando embedded intern candidates from October 2026 describe a single hiring manager round. One says the manager ran every software interview at the site and asked "around 8 easy C++ questions" in 30 minutes, among them what the static and virtual keywords do. The other got C++ keywords, OOP and multithreading, then a simple sort question at the end.
Each question below carries the year candidates reported it, and the answers are short because the round is fast. The OOP pillars and polymorphism have their own lesson, and threads and deadlock live in Data Structures, Threads & Deadlock.
What the Lockheed Martin C++ round looks like
- Who asks: the hiring manager. Sometimes a lead or a second manager sits in.
- How many: about 8 to 12 questions. One 2026 intern round was 30 minutes in total, intro included.
- Format: spoken answers, no editor. A short sort question closed one 2026 Orlando round.
- Who gets it: embedded roles most. Fort Worth, Syracuse and Sunnyvale software teams ask it too.
Seniority doesn't make it go away. A Fort Worth senior engineer in December 2023 had a one hour call with two managers, and the last part was "Technical questions about C++, these were pretty basic." In November 2024 a Syracuse senior hire spent half the interview on STAR stories and half on C++. One early-career candidate in June 2022 called them "Standardized C++ fundamental questions for early careers." The questions barely change with level. What changes is how much the manager pushes on a follow-up.
Some teams go further. A Sunnyvale panel in October 2026, with a director, a manager and a team lead, talked through data structures and converting C code to C++, and the candidate came away saying you "would need at least knowledge of C++17". Others stop short: a Littleton candidate in August 2026 was only asked about their C++ skill set. Prepare for the long version.
The questions, with short spoken answers
What does the static keyword do? (2026, 2022)
The October 2026 Orlando intern manager asked it, and a 2022 Orlando candidate was asked "What is a static variable?" The keyword means different things in different places, and naming all three makes a complete answer.
Inside a function, a static local is created once and keeps its value between calls. On a class member, static means one copy shared by every object, and a static member function has no this, so it can't touch instance data. At file scope, static gives a variable or function internal linkage, so it's invisible to other translation units. Lead with the one you use most, then list the others.
int next_id() { static int counter = 0; // created once, survives between calls return ++counter; // 1, 2, 3, ...}class Sensor {public: static int sensor_count; // one copy shared by every Sensor static void reset_count() { sensor_count = 0; } // no this pointer};int Sensor::sensor_count = 0;static int file_only_value = 42; // internal linkage: this file onlyWhat do virtual and pure virtual functions do? (2026, 2022)
The 2026 Orlando manager asked about the virtual keyword along with static. A 2022 Orlando candidate got the fuller version, "Virtual and pure virtual functions. What they are and how they are used?"
A virtual function is picked at run time by the real type of the object, even when you call it through a base pointer or reference. That is dynamic dispatch, and compilers usually build it with a table of function pointers per class, the vtable. A pure virtual function, written = 0, is a promise without an implementation. It makes the class abstract, so you can't create one, and every concrete subclass must override it. In practice a pure virtual base class is how C++ spells an interface.
class Shape {public: virtual double area() const = 0; // pure virtual: Shape is abstract virtual ~Shape() = default; // virtual destructor};class Circle : public Shape {public: explicit Circle(double radius) : radius(radius) {} double area() const override { return 3.14159 * radius * radius; }private: double radius;};Shape* shape = new Circle(2.0);double result = shape->area(); // Circle::area runs, chosen at run timedelete shape; // safe only because ~Shape is virtualConverting C to C++, and what C++17 adds (2026)
The October 2026 Sunnyvale panel talked about converting C to C++ and expected C++17. The question underneath is how you'd modernize C code without breaking it, so give the moves in order of payoff. Replace malloc and free with RAII types such as std::vector and std::unique_ptr, and #define constants with constexpr. Swap plain enums for enum class, raw arrays for std::array, and C casts for static_cast.
Then group loose functions and the struct they act on into a class. Keep the C interface with extern "C" while the inside changes, and lean on tests so behavior stays the same.
For C++17, a handful of features is enough to sound fluent. std::optional replaces "return -1 if not found". Structured bindings unpack a pair or struct in one line. if constexpr picks a branch at compile time inside a template. std::string_view reads a string without copying it. And when you need a type-safe union, there's variant.
// C style#define MAX_TRACKS 64int find_track(int track_id); // returns -1 if not found// C++17 styleconstexpr int max_tracks = 64;std::optional<Track> find_track(int track_id);if (auto track = find_track(7)) { // no magic -1 auto [latitude, longitude] = track->position(); // structured binding}What does volatile mean in C++? (2024)
An Orlando software engineer was asked in June 2024: "What does the 'volatile' keyword mean in C++ source code?" It is an embedded favorite because the answer has a trap in it.
volatile tells the compiler that a variable can change in ways the code can't see, so every read and write must really happen in memory. The compiler may not keep it in a register or drop a read that looks redundant. Use it for memory-mapped hardware registers and for a flag an interrupt handler sets.
Then say the trap out loud. volatile does not make code thread-safe. It gives no atomicity and no ordering between threads, so a counter two threads bump is still a race. For threads, reach for an atomic or a mutex.
// Memory-mapped status register (the address is made up)volatile unsigned int* const status_register = reinterpret_cast<volatile unsigned int*>(0x40001000);volatile bool data_ready = false; // set by an interrupt handlervoid wait_for_data() { while (!data_ready) { // without volatile, the compiler may read data_ready once // and spin forever }}Lockheed has written this answer down. Its Joint Strike Fighter Air Vehicle C++ Coding Standards (Dec 2005, public release) say volatile "shall not be used unless directly interfacing with hardware." The same document bans heap allocation after initialization and bans exceptions. Skim it before an embedded interview; it reads a lot like the answer key to this round.
What is a pointer, and how is it different from a reference? (2022-2025)
No C++ question comes up more often. A February 2025 candidate was asked to "Define a pointer," and a Palmdale embedded candidate got "What is a pointer?" in 2023. Palmdale (2022), Liverpool, New York (2023) and Orlando (2022) all asked pointer versus reference, and the Orlando manager added "When would you use one over the other?"
A pointer is a variable that holds an address. It can be null, it can be pointed somewhere else later, and you can do arithmetic on it. A reference is another name for an existing object. It must be bound when it's created, it can't be reseated, and in valid code it is never null.
For "when", use a reference when the thing must exist, as in most function parameters, and a const reference to pass something big without copying it. Use a pointer when the object might be absent, when you need to point at something else later, or when you're walking an array, calling a C API or reading a hardware address.
int speed = 100;int limit = 250;int* speed_ptr = &speed; // holds the address of speed*speed_ptr = 120; // speed is now 120speed_ptr = &limit; // reseated: now points at limitspeed_ptr = nullptr; // allowedint& speed_ref = speed; // another name for speed, bound for lifespeed_ref = 130; // speed is now 130speed_ref = limit; // copies 250 into speed; does NOT rebindvoid print_track(const Track& track); // must exist, no copyTrack* find_track(int track_id); // may return nullptrWhat is a smart pointer? (2023)
The January 2023 Liverpool, New York candidate got this in the same interview as pointer versus reference. A smart pointer is a class that owns a heap object and deletes it in its destructor, so you can't forget to free it, even when a function returns early. That's RAII.
Name the three. A unique_ptr is sole ownership. It can be moved but not copied, and it costs nothing over a raw pointer. A shared_ptr keeps a reference count and deletes when the last owner goes away. A weak_ptr watches a shared object without owning it, which is how you break a cycle of two objects holding each other. Default to unique_ptr. On flight software the heap may be off limits after startup anyway, as the JSF rules in the volatile section show.
#include <memory>auto radar = std::make_unique<Radar>(); // sole ownerauto moved_radar = std::move(radar); // ownership moves; radar is now nullauto config = std::make_shared<Config>(); // count = 1auto config_copy = config; // count = 2std::weak_ptr<Config> watcher = config; // does not change the countif (auto still_alive = watcher.lock()) { // use still_alive while it exists}What is the difference between a struct and a class? (2023)
An Orlando panel of two hiring managers asked this in March 2023. In C++ there is exactly one language difference: struct members and base classes are public by default, class ones are private. Everything else is the same, including methods, constructors and inheritance.
The useful second sentence is about convention. Use a struct for plain data with no rules between its fields, and a class when it guards an invariant behind private members. Lockheed's JSF standard says the same thing in its own words. A New York candidate in February 2023 got the related "What does the public keyword mean?", so be ready to explain public, protected and private in one breath.
struct Waypoint { // members public by default double latitude; double longitude;};class FuelTank { // members private by defaultpublic: void add(double liters) { if (liters > 0) level += liters; } double current() const { return level; }private: double level = 0; // guarded: never negative};Shallow copy versus deep copy (2023)
A March 2023 associate candidate was asked "What is the difference between a shallow copy and a deep copy?" With a shallow copy the members are copied as they are, so a pointer member gets copied and both objects now point at the same buffer. A deep copy allocates a new buffer and copies the contents, so each object owns its own.
The compiler's default copy constructor is shallow. For a class that owns a raw pointer, that means two objects free the same memory, a double delete. The fix is the rule of three: write the copy constructor, the copy assignment and the destructor together. Better still, hold a std::vector or a smart pointer and let the defaults do the right thing.
class Buffer {public: explicit Buffer(int size) : size(size), data(new int[size]) {} Buffer(const Buffer& other) // deep copy : size(other.size), data(new int[other.size]) { std::copy(other.data, other.data + size, data); } Buffer& operator=(const Buffer& other); // same idea ~Buffer() { delete[] data; }private: int size; int* data;};What are templates? (2020)
Templates came up at Marietta in January 2020, alongside classes and pointers. It's the oldest question on this list, so give it less time than the others. A template is code written once with the type left as a parameter. The compiler stamps out a real version for each type you use, at compile time, so there's no run-time cost like there is with virtual calls. The price is longer builds, bigger binaries and error messages that run for pages.
template <typename T>T clamp_value(T value, T low, T high) { if (value < low) return low; if (value > high) return high; return value;}int altitude = clamp_value(52000, 0, 50000); // T = intdouble heading = clamp_value(370.5, 0.0, 360.0); // T = doubleHow to answer fast without sounding rehearsed
Each answer has the same three beats: what it is, one place you'd use it, and the catch. "volatile forces every access to memory. I'd use it on a hardware register. It doesn't make anything thread-safe." Three sentences, and you're done before the manager's next breath. If they want more, they'll ask.
Tie an answer to your own work when you honestly can. "We used a static counter for message IDs on my capstone" lands better than a textbook line, and these managers also want to hear what you've built. Don't guess on a keyword you don't know. Say what you'd check and move on, because the next question is ten seconds away.
Do
- Answer in two or three sentences, then stop
- Name the catch: thread safety for volatile, the virtual destructor for virtual
- Give a real use from your projects when you have one
Don't
- Recite every rule you know about a keyword
- Say volatile makes a variable thread-safe
- Bluff a feature you have never used; the follow-up will find it
Older problems (2011-2022)
Before 2023 some managers handed over code instead of asking keywords. Eight reports from 2011 to 2022 describe reading a short snippet, saying what it prints or what's wrong, and fixing it. None of them is from the last three years, so treat this as a backup format. The snippets below are illustrations of the shape candidates describe, not the code they saw.
Read the code and say what is wrong (2020-2022)
The newest reports of this format look alike. An October 2022 candidate was given a snippet and asked to "describe what it does and if there's anything wrong with it." At a November 2022 hiring fair, a candidate got "how to resolve errors in code" questions. In May 2021 an SWE II candidate read C++ and said "what the output will be", then spotted mistakes. A July 2021 Zoom panel included "some code review questions on C."
Read these out loud, line by line, the way a reviewer would. Say what each line does, then check the usual suspects. Look for a pointer used after it's freed, an index one past the end, an integer that overflows or truncates, or a missing null check. A missing break in a switch and an uninitialized variable are common too. In C, add a buffer with no length check and a returned pointer to a local.
A January 2020 King of Prussia candidate got the debugging version: something like "How would you go about debugging a program where the expected output is 14 but it returns 12?" There's no code, so the answer is a method. Reproduce it with the smallest input that fails, then check the boundaries, since a gap of two often means a loop that skips its first or last item. Print or step through the values at each stage until they part from what you expect, then add a test for the case.
Three snippets at a hiring event (2019)
A September 2019 candidate at a hiring event near LAX "was handed 3 code snippets, and asked to either find out what they would evaluate to, or how they could be improved." The first was something like the output of dereferencing a pointer to an int. The second hid a divide-by-zero edge case, and the third had three similar classes to fold into one base class with inherited members.
// 1. What does this print?int count = 5;int* count_ptr = &count;*count_ptr += 2;std::cout << count; // 7: the write went through the pointer// 2. What input breaks this?double average(int total, int samples) { return total / samples; // samples == 0 divides by zero,} // and int / int also drops the fraction// 3. How would you improve this?class Truck { std::string name; int wheels; void describe(); };class Car { std::string name; int wheels; void describe(); };class Bike { std::string name; int wheels; void describe(); };// Move name, wheels and describe() into a Vehicle base classFor the divide-by-zero one, say both bugs. A zero count crashes or gives undefined behavior, and integer division truncates even when it doesn't. Then fix both: guard the zero case and decide what to return, and convert to double before dividing. For the classes, the move is a Vehicle base with the shared members and a virtual describe each subclass overrides.
Which method runs, Employee or Manager? (2011)
The oldest report, a San Jose onsite in November 2011, had an Employee class and a Manager class that inherits from it. A variable set to a new Manager prints the ID, and the question is which class's method runs. The answer turns on one word. If the method is virtual, Manager's version runs through a base pointer. If it isn't, the declared type wins and Employee's runs.
class Employee {public: virtual std::string describe_id() const { return "Employee"; } std::string plain_id() const { return "Employee"; } virtual ~Employee() = default;};class Manager : public Employee {public: std::string describe_id() const override { return "Manager"; } std::string plain_id() const { return "Manager"; }};Employee* person = new Manager();person->describe_id(); // "Manager": virtual, chosen by the real typeperson->plain_id(); // "Employee": not virtual, chosen by the pointer typeA 2014 UK senior candidate also had to improve a few lines of sample code with no context, and felt there was one expected answer. That fits the older pattern. If you get a snippet today, say every issue you see, then ask which one they care about.
Key Takeaways
- ✓Expect about 8 to 12 spoken C++ questions from the hiring manager, with no code to write.
- ✓Know three meanings of static, and pair virtual with the virtual destructor follow-up.
- ✓volatile is for hardware registers and interrupt flags; it does not make code thread-safe.
- ✓Code-reading questions are 2011 to 2022; read line by line and name each bug you see.
Lockheed Martin interview guideKnow what Lockheed Martin asks before you walk in.
14 coding · 3 system design · 50 behavioral questions
Get their questions first.
InterviewLegend is independent and not affiliated with or endorsed by any company it covers.