Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9242439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:34:47+00:00 2026-06-18T08:34:47+00:00

My c++ book (lippman, c++ primer, fifth ed., p. 508) provides these 4 rules

  • 0

My c++ book (lippman, c++ primer, fifth ed., p. 508) provides these 4 rules for figuring out when the compiler will synthesize the copy control and default constructor as deleted members:

  • The synthesized destructor is defined as deleted if the class has a member whose own destructor is deleted or inaccessible (e.g. private).

  • The synthesized copy constructor is defined as deleted if the class has a member whose own copy constructor is deleted or inaccessible. It is also deleted if the class has a member with a deleted or inaccessible destructor.

  • The synthesized copy-assignment operator is defined as deleted if a member has a deleted or inaccessible copy-assignment operator, or if the class has a const or reference member.

  • The synthesized default constructor is defined as deleted if the class has a member with a deleted or inaccessible destructor; or has a reference member that does not have an in-class initializer; or has a const member whose type does not explicitly define a default constructor and that member does not have an in-class initializer.

I’m failing to see how these rules explain the SECOND error here:

class Foo {
public:
  Foo(int i) { }
};

class Bar {
private:
  Foo foo;
};

int main() {
  Foo foo; //error: no matching constructor in Foo
  Bar bar; //error: implicitly deleted constructor in Bar
  return 0;
}

The first error is understandable and has nothing to do with this question directly. The second error is surprising because the above rules not explain why Bar should get its default constructor synthesized as deleted.

what rules is my book missing, or am I not grasping the rules?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:34:47+00:00Added an answer on June 18, 2026 at 8:34 am

    Foo has no default constructor because you declare a constructor; from C++11 12.1/5:

    If there is no user-declared constructor for class X, a constructor having no parameters is implicitly declared
    as defaulted

    Bar has a deleted default constructor because Foo has no default constructor; from C++11 12.1/5 (5th bullet point):

    A defaulted default constructor for class X is defined as deleted if […] any […] non-static data member […] has no default constructor

    The “rules” you quote do seem to be missing that point, only mentioning the case of const-qualified members in the 3rd bullet point.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My c++ book says this (lippman, c++ primer, fifth ed., p. 508): The synthesized
In the Book C++ Primer by Stanley B. Lippman* , * Josée Lajoie in
The book 'Modern Compiler Design' is the nice book about compilers. In its source
String manipulation problem http://www.ideone.com/qyTkL In the above program (given in the book C++ Primer,
The book C++ Primer says For most applications, in addition to being safer, it
I had been going through the Book: C++ Primer, Third Edition By Stanley B.
In - C++ Primer, Third Edition By Stanley B. Lippman, Josée Lajoie It says
The book I am reading says that after allocating an object I need to
Q1 Book suggests that before we register new SqlProfileProvider , we should remove any
Each book can have many authors. And each author can author many books. class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.