← Trexquant Interview Insights

Trexquant·Software Engineer·Technical Phone Screen·Senior

Senior
Jun 2026

Summary

Trexquant software engineer interview that went deep into C++ internals, specifically the rules around implicit default constructor generation. Pretty niche stuff, not your typical leetcode grind.

Questions Asked (4)

Q1

Under what conditions will the compiler implicitly declare a default constructor for a class, and when does that implicitly-declared constructor end up being defined as deleted?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Two-part question that sounds like one.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First clarify that the question is about the implicitly-declared default constructor, not the default constructor in general. Then explain the conditions under which it is declared (when no user-declared constructors exist) and the conditions under which it is defined as deleted (e.g., due to non-default-constructible members or bases, or reference members without initializers). Finally, emphasize that a deleted default constructor still participates in overload resolution.

Pro tip: Mention that the implicitly-declared default constructor is defined as deleted if any non-static data member or base class has a non-trivial default constructor that is deleted or inaccessible, or if the class has a reference member without a default initializer. This shows deep understanding of C++ object model rules.

1. Clarify the question

State that you are discussing the implicitly-declared default constructor, which is a special member function. Distinguish it from the default constructor that might be user-provided.

2. Conditions for implicit declaration

Explain that the compiler implicitly declares a default constructor if the class has no user-declared constructors. Note that this declaration is public and inline.

3. Conditions for deleted definition

List the cases where the implicitly-declared default constructor is defined as deleted: a non-static data member or base class with a deleted or inaccessible default constructor, a reference member without a default initializer, a const member without a default initializer and without a user-provided default constructor, or a member of a type with a non-trivial default constructor that is not accessible.

4. Consequences of deletion

Explain that a deleted default constructor still exists and participates in overload resolution, but using it is ill-formed. This means the class is not default-constructible.

5. Summarize with examples

Provide a concise example, such as a class with a reference member or a const member without initializer, to illustrate when the default constructor is deleted.

Key Points to Mention

  • Implicit declaration occurs only if there are no user-declared constructors.
  • The implicitly-declared default constructor is defined as deleted if any non-static data member or base class has a deleted or inaccessible default constructor.
  • A reference member without a default initializer causes the default constructor to be deleted.
  • A const member without a default initializer and without a user-provided default constructor causes deletion.
  • A member with a non-trivial default constructor that is not accessible (e.g., private) causes deletion.
  • A deleted default constructor still participates in overload resolution, making the class non-default-constructible.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How do user-declared special member functions like copy/move constructors, copy/move assignment operators, and destructors affect whether a default constructor gets generated at all?

Technical Trade-offsSystem Design
Author's notes

This one I actually knew cold.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the default constructor is only implicitly declared if there are no user-declared constructors, and that other special member functions (copy/move operations, destructor) do not suppress it. Then explain the nuanced interactions: a user-declared destructor or copy/move operation can affect move constructor generation, but not the default constructor. Finally, mention that if any constructor is user-declared, the default constructor is not generated, but it can be explicitly defaulted.

Pro tip: Emphasize that the rules are about *user-declared* constructors, not other special member functions, and that the default constructor is unique in this regard. Also note that 'user-declared' includes explicitly defaulted or deleted functions.

1. Define the default constructor and its implicit generation

State that a default constructor is one callable with no arguments, and the compiler implicitly declares one only if the class has no user-declared constructors.

2. List the special member functions and their categories

Separate constructors (default, copy, move) from assignment operators and destructor, noting that only constructors affect default constructor generation.

3. Explain the effect of user-declared constructors

Clarify that any user-declared constructor (including copy/move constructors) suppresses the implicit default constructor, but user-declared copy/move assignment operators or destructor do not.

4. Discuss interactions with move operations and destructor

Mention that a user-declared destructor or copy operation inhibits implicit move constructor/assignment, but this does not impact default constructor generation.

5. Summarize with a rule of thumb and mention explicit defaulting

Conclude that only user-declared constructors suppress the default constructor, and that you can use '= default' to explicitly request it if needed.

Key Points to Mention

  • The default constructor is implicitly declared only if there are no user-declared constructors.
  • User-declared copy/move constructors count as constructors and thus suppress the default constructor.
  • User-declared copy/move assignment operators and destructors do not affect default constructor generation.
  • A user-declared destructor or copy operation inhibits implicit move operations, but this is separate from default constructor rules.
  • The default constructor can be explicitly defaulted with '= default' even if other constructors are declared.
  • The term 'user-declared' includes explicitly defaulted or deleted functions.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

What happens to the implicit default constructor when a class has members or base classes with no default constructor, or when members are references or const-qualified?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Tripped me up more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining the implicit default constructor and the conditions under which the compiler generates it. Then explain that it is not generated (or is defined as deleted) when any member or base class lacks an accessible default constructor, or when a member is a reference or const-qualified without a default initializer. Finally, discuss the consequences: the class becomes non-default-constructible, and any attempt to default-construct it results in a compile-time error.

Pro tip: Mention that in C++11 and later, you can use `= default` to explicitly request the compiler-generated default constructor, but it will still be deleted if the class has non-default-constructible members. Also note that the rule applies recursively: if a base class's default constructor is deleted, the derived class's implicit default constructor is also deleted.

1. Define the implicit default constructor

Explain that the compiler implicitly declares a default constructor if no user-declared constructors exist. It is used to default-initialize objects.

2. Identify conditions that prevent its generation

List the cases: a member or base class has no default constructor (or it is inaccessible/deleted), a member is a reference, or a member is const-qualified without a default member initializer.

3. Explain the outcome: deleted or not declared

Clarify that in such cases, the implicit default constructor is defined as deleted (since C++11) or not generated at all (pre-C++11). This makes the class non-default-constructible.

4. Discuss implications and workarounds

Mention that any attempt to default-construct the class will fail at compile time. To fix, provide a user-defined default constructor that initializes the problematic members, or use default member initializers.

Key Points to Mention

  • The implicit default constructor is only generated if there are no user-declared constructors.
  • A member or base class without an accessible default constructor causes the implicit default constructor to be deleted.
  • Reference members must be initialized, so they prevent the implicit default constructor unless a default member initializer is provided.
  • Const-qualified members without a default member initializer also prevent the implicit default constructor.
  • In C++11 and later, the compiler defines the default constructor as deleted rather than not declaring it.
  • The rule is recursive: if a base class's default constructor is deleted, the derived class's implicit default constructor is also deleted.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

Can you give concrete examples of a class that gets an implicit default constructor, one that does not get one at all, and one that gets one but it is defined as deleted?

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Straightforward once you've answered the theory parts.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying that the implicit default constructor is only generated when no user-declared constructors exist, then give one clear example for each case: a class with no constructors, a class with any user-declared constructor, and a class with a member or base that makes the default constructor deleted. Keep the examples minimal and focus on the underlying rules rather than memorized trivia.

Pro tip: Mention that a deleted default constructor is still a declared constructor, so it participates in overload resolution and can cause a compile error if used—this shows you understand the difference between 'not declared' and 'declared as deleted'.

1. State the rule for implicit default constructor generation

Explain that the compiler generates a default constructor only if the class has no user-declared constructors. Also note that it is defined as deleted if a non-static data member or base class has a deleted or inaccessible default constructor, or if it has a reference member without a default initializer.

2. Give an example of a class that gets an implicit default constructor

Provide a simple class with no user-declared constructors, e.g., `struct A { int x; };`. The compiler implicitly declares `A::A()`.

3. Give an example of a class that does not get a default constructor at all

Provide a class with any user-declared constructor, e.g., `struct B { B(int) {} };`. Because a constructor is user-declared, no implicit default constructor is generated.

4. Give an example of a class that gets a deleted default constructor

Provide a class with a member that has a deleted default constructor, e.g., `struct C { std::mutex m; };` or `struct D { D() = delete; };`. The compiler declares the default constructor as deleted.

5. Summarize the distinction and implications

Emphasize that 'not declared' means the constructor does not exist in overload resolution, while 'deleted' means it exists but cannot be used. This affects error messages and SFINAE contexts.

Key Points to Mention

  • Implicit default constructor is generated only when there are no user-declared constructors.
  • A user-declared constructor (including copy/move constructors) suppresses the implicit default constructor.
  • A default constructor is defined as deleted if a non-static data member or base class has a deleted or inaccessible default constructor.
  • A reference member without a default initializer also causes the default constructor to be deleted.
  • Deleted functions participate in overload resolution, unlike functions that are not declared.
  • Use `= default` to explicitly request the compiler-generated default constructor, and `= delete` to explicitly forbid it.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.