С++ для интервью
37 subscribers
10 photos
Готовься к собеседованиям по C++ эффективно: реальные вопросы, типичные HR уловки, примеры кода и объяснения.
Каждый пост — один шаг ближе к офферу 💼
Download Telegram
🤯 Работа с auto
int x = 10;
auto f() { return (x); }
Please open Telegram to view this post
VIEW IN TELEGRAM
Что вернёт f()?
Anonymous Quiz
80%
int
0%
int&
20%
const int&
👍4
🔍 Есть ли ошибка в коде ниже?
std::string_view f() {
return std::string("hello");
}
Please open Telegram to view this post
VIEW IN TELEGRAM
std::unique_ptr и move
std::unique_ptr<int> a = std::make_unique<int>(5);
auto b = a;
🍿 Как поведет себя функция?
int x = 10;
auto f = [=]() mutable { ++x; };
f();
Please open Telegram to view this post
VIEW IN TELEGRAM
Работа с constexpr
constexpr int f(int x) { return x * 2; }
int y = f(10);
👍5
Концепция SFINAE
template<class T>
auto f(T t) -> decltype(t.size()) {}
👍3
Когда эта функция участвует в перегрузке?
Anonymous Quiz
33%
Всегда
50%
Когда есть метод size
17%
Только для stl контейнеров
❤4👍1
Использование optional
std::optional<int> o;
*o = 5;
Использование variant
std::variant<int, std::string> v = "hi";
std::get<int>(v);
⚙️ Использование mutable
struct S {
mutable int x;
void f() const { ++x; }
};
🔥4👍1
🔍 explicit конструктор
struct A {
explicit A(int);
};
A a = 5;
Please open Telegram to view this post
VIEW IN TELEGRAM
🔥5❤3👍2
Код выше корректный?
Anonymous Quiz
33%
Да
50%
Нет
17%
Только с C++20 и выше
🔥5👍4🥰2