C and C++ Coding Flashcards
7 cards from real Online Coding Lessons practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 7 C and C++ Coding flashcards as text
What is a dangling pointer in C?
Answer: A pointer to freed or out-of-scope memory
A dangling pointer references memory that has been freed or has gone out of scope.
In C++, which feature allows a function to operate on multiple types using a single definition?
Answer: Templates
Templates let you write generic code that works with any type.
What does the 'static' keyword do for a local variable inside a C function?
Answer: Preserves its value between calls
A static local variable retains its value across multiple function calls.
Which C++ smart pointer ensures exclusive ownership of a resource?
Answer: std::unique_ptr
std::unique_ptr enforces sole ownership and cannot be copied.
What is the output type of the C comparison expression (5 > 3)?
Answer: An int with value 1
In C, relational expressions evaluate to an int, 1 for true and 0 for false.
In C++, what is the purpose of a destructor?
Answer: Clean up resources when an object is destroyed
A destructor releases resources and runs automatically when an object goes out of scope.
What does the preprocessor directive #include do in C?
Answer: Inserts the contents of another file
#include textually inserts the named header's contents before compilation.