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

  • Home
  • SEARCH
  • 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 8659745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:05:03+00:00 2026-06-12T16:05:03+00:00

class C { public: C() { } }; class B { public: B(C c)

  • 0
class C {
public:
    C() { }
};

class B {
public:
    B(C c) { }
    B() { }
};

class A {
public:
    A(bool b) { }
    A(B b) { }
};

int main() {
    A a1 = true; // bool -> A        is allowed
    A a2 = B();  // B -> A           is allowed

    A a3 = 7;    // int -> bool -> A is allowed
    A a4 = C();  // C -> B -> A      isn't allowed
}

Why I can use two-step implicit conversion with bool but can’t use it with C?
What is the general rule describing multistep implicit conversion?

  • 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-12T16:05:04+00:00Added an answer on June 12, 2026 at 4:05 pm

    There is no multi-step user-defined implicit conversion.

    int -> bool -> A
    

    is allowed because the int->bool conversion isn’t user-defined.

    12.3 Conversions [class.conv]

    1 Type conversions of class objects can be specified by constructors
    and by conversion functions. These conversions are called user-defined
    conversions and are used for implicit type conversions (clause 4), for
    initialization (8.5), and for explicit type conversions (5.4, 5.2.9).

    2 User-defined conversions are applied only where they are unambiguous
    (10.2, 12.3.2). Conversions obey the access control rules (clause 11).
    Access control is applied after ambiguity resolution (3.4).

    3 [ Note:
    See 13.3 for a discussion of the use of conversions in function calls
    as well as examples below. —end note ]

    4 At most one user-defined
    conversion (constructor or conversion function) is implicitly applied
    to a single value.

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

Sidebar

Related Questions

In the following code: class SomeClass { vector<int> i; vector<bool> b; public: int& geti()
I have made the following code:- class A{ bool bFlag[2]; public: A(){ for(int i
i use simple bool pointer class member. Assigning false resp. true behaves different -
Given the sample code: class Base { public: bool pub; protected: bool prot; };
i have a class like [Serializable] public class MyClass { [XmlAttribute] public bool myBool
class Widget; std::vector< std::shared_ptr<Widget> > container class Criterium { public: bool operator()(const Widget& left,
All, I have a simple class. public class Container : UserControl { public bool
Basically, I have the following so far: class Foo { public override bool Equals(object
public class ToolPartGetLists : Microsoft.SharePoint.WebPartPages.WebPart, ICommunicationInterface { private bool _error = false; //......... protected
public class Demo { public void When(Func<Person, bool> condition) { if (!condition) { Log.Info(Condition

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.