FlashKeepers

C and C++ · College · College and University

C++ V: Modern C++ (11 to 20)

auto, range-for, move semantics, constexpr, structured bindings, std::optional, std::variant, modules, coroutines and the spaceship operator.

About this set

40 basic cards for College C and C++. Set 5 of 7 in C++. It opens with "What does auto do in C++11?" and "Can you use auto with function return types in C++14?". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What does auto do in C++11?
Show answerDeduces the type of a variable from its initializer
Can you use auto with function return types in C++14?
Show answerYes, a function can return auto and the return type is deduced from return statements
What is the type of x in: auto x = 5;
Show answerint
What happens if auto is used for a variable with no initializer?
Show answerCompile error; auto requires an initializer to deduce the type
What C++ version introduced range-based for loops?
Show answerC++11
What is the syntax for a range-based for loop?
Show answerfor (type element : container) { ... }
What does a range-based for loop require from a container?
Show answerbegin() and end() member functions, or external begin/end functions in the same namespace
What is an rvalue reference in C++11?
Show answerA reference to a temporary object, declared with &&
What is the difference between copy and move semantics?
Show answerCopy creates a new independent copy; move transfers ownership of resources to avoid duplication
What keyword forces move semantics when passing an lvalue?
Show answerstd::move
What is a move constructor?
Show answerA constructor that takes an rvalue reference and transfers resources from the temporary
Can you call a move constructor with an lvalue?
Show answerOnly if you explicitly use std::move to cast it to an rvalue reference
What does constexpr mean in C++?
Show answerThe expression or function can be evaluated at compile time to produce a constant
Can a constexpr function also run at runtime?
Show answerYes, if the inputs are not compile-time constants, the compiler generates runtime code
What is consteval (C++20)?
Show answerA function that must always be evaluated at compile time, never at runtime

25 more cards in the app

Study this set free