Quick Revision

GK One-Line Question & Answer

15541+ short questions with short answers, covering every category and sub-category on the site — no long articles to scroll through. Good for a fast recap before an exam, or a few minutes of daily practice.

OOP Using C++ → Introduction to C++ 40

What is the output: auto x=0xDEAD; cout<<hex<<x;
dead
click to copy
What is 'std::jthread' stop_source?
Provides stop_token to request cooperative cancellation
click to copy
What is the output: int x=5; cout<<(x&(~0<<2));
4
click to copy
What is 'deducing this' (C++23)?
Both B and C
click to copy
What is the output: int x=0b11110000; cout<<(x>>4&0xF);
15
click to copy
What is 'std::mdspan'?
Non-owning multidimensional array view (C++23)
click to copy
What is the output: constexpr int f(int n){return n<=1?1:n*f(n-1);} static_assert(f(5)==120); cout<<'Y';
Y
click to copy
What is 'std::print' in C++23?
Type-safe formatted output (like Python print)
click to copy
What is the output: int x=255; cout<<setw(8)<<hex<<x;
ff
click to copy
What is 'std::flat_map' in C++23?
Sorted associative container stored in flat arrays (cache-friendly)
click to copy
What is the output: int x=5; cout<<boolalpha<<(x>0)<<' '<<(x<0);
true false
click to copy
What is 'std::generator' in C++23?
Coroutine-based range generator
click to copy
What is the output: int x=42; cout<<oct<<x<<' '<<hex<<x<<' '<<dec<<x;
52 2a 42
click to copy
What is 'ranges::to' in C++23?
Converts a range to a container: views::filter(...)|ranges::to<vector>()
click to copy
What is the output: int x=5; cout<<showpos<<x<<' '<<-x;
+5 -5
click to copy
What is 'std::move_only_function' vs std::function?
move_only_function holds non-copyable callables
click to copy
What is the output: cout<<setfill('0')<<setw(5)<<42;
00042
click to copy
What is 'std::string_view::substr'?
Returns a string_view of a sub-range (no allocation)
click to copy
What is the output: string s="hello"; string_view sv=s; cout<<sv.substr(1,3);
ell
click to copy
What is 'std::chrono::hh_mm_ss'?
Splits duration into hours, minutes, seconds (C++20)
click to copy
What is the output: int x=5; cout<<(x==5?'Y':'N')<<(x!=5?'Y':'N');
YN
click to copy
What is 'std::flat_set' in C++23?
Sorted unique set in flat sorted vector
click to copy
What is the output: int x=10; cout<<(x%3==0?'D':x%3==1?'R':'M');
R
click to copy
What is 'std::expected::and_then'?
Chains operation on success value
click to copy
What is the output: int x=7; cout<<(x|x<<1|x<<2);
31
click to copy
What is 'std::stacktrace' in C++23?
Captures and prints current call stack at runtime
click to copy
What is the output: auto x=1; auto y=2; cout<<(x<=>y<0);
1
click to copy
What is 'std::inplace_vector' in C++26?
Fixed-capacity vector stored inline (no heap)
click to copy
What is the output: int x=5; cout<<__builtin_clz(x);
29
click to copy
What is 'std::ranges::zip' (C++23)?
Creates range of tuples from multiple ranges
click to copy
What is the output: int x=5; auto f=[x]()mutable->int{return x++;}; cout<<f()<<f()<<f();
Unspecified order
click to copy
What is 'std::ranges::chunk' (C++23)?
Splits range into fixed-size sub-ranges
click to copy
What is the output: int x=0b10101010; cout<<__builtin_popcount(x);
4
click to copy
What is 'std::views::enumerate' (C++23)?
Both A and B
click to copy
What is the output: int x=5; cout<<(x*(x+1)/2);
15
click to copy
What is 'std::unreachable' in C++23?
Tells compiler a point is unreachable; UB if reached
click to copy
What is the output: int x=0xFF00; cout<<(x>>8);
255
click to copy
What is 'std::ranges::slide' (C++23)?
Sliding window view of size N
click to copy
What is the output: int x=42; cout<<bitset<8>(x);
00101010
click to copy
What is 'std::indirect' in C++26?
Value-semantics smart pointer with deep copy
click to copy