PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches
|Home/Software Engineering Fundamentals/Trexquant

Explain C++ default constructor generation rules

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of C++ special-member-function rules—specifically when the compiler implicitly declares a default constructor, when that implicitly-declared constructor is defined as deleted, and how user-declared copy/move constructors, copy/move assignments, destructors, and member/base types (const, reference, or non-default-constructible) affect generation. Commonly asked to assess mastery of language semantics and object-initialization pitfalls, it belongs to the Software Engineering Fundamentals domain and tests both conceptual understanding of compiler behavior and practical application in C++ code.

  • medium
  • Trexquant
  • Software Engineering Fundamentals
  • Software Engineer

Explain C++ default constructor generation rules

Company: Trexquant

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

You are given a C++ class type `T`. 1. When will the compiler **implicitly declare** a default constructor for `T`? 2. When will the implicitly-declared default constructor be **defined as deleted** (i.e., `T t;` is ill-formed)? 3. How do user-declared special member functions (copy/move ctor, copy/move assignment, destructor) affect whether a default constructor is generated? 4. What changes if members/base classes have no default constructors, are references, or are `const`? Answer in terms of the C++ “special member functions” model (rule of 0/3/5) and include a few small examples of classes that: - get an implicit default constructor, - do not get one, - get one but it is deleted.

Quick Answer: This question evaluates understanding of C++ special-member-function rules—specifically when the compiler implicitly declares a default constructor, when that implicitly-declared constructor is defined as deleted, and how user-declared copy/move constructors, copy/move assignments, destructors, and member/base types (const, reference, or non-default-constructible) affect generation. Commonly asked to assess mastery of language semantics and object-initialization pitfalls, it belongs to the Software Engineering Fundamentals domain and tests both conceptual understanding of compiler behavior and practical application in C++ code.

Trexquant logo
Trexquant
Sep 1, 2025, 12:00 AM
Software Engineer
Onsite
Software Engineering Fundamentals
2
0

You are given a C++ class type T.

  1. When will the compiler implicitly declare a default constructor for T ?
  2. When will the implicitly-declared default constructor be defined as deleted (i.e., T t; is ill-formed)?
  3. How do user-declared special member functions (copy/move ctor, copy/move assignment, destructor) affect whether a default constructor is generated?
  4. What changes if members/base classes have no default constructors, are references, or are const ?

Answer in terms of the C++ “special member functions” model (rule of 0/3/5) and include a few small examples of classes that:

  • get an implicit default constructor,
  • do not get one,
  • get one but it is deleted.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Software Engineering Fundamentals•More Trexquant•More Software Engineer•Trexquant Software Engineer•Trexquant Software Engineering Fundamentals•Software Engineer Software Engineering Fundamentals
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.