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 8273241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:24:32+00:00 2026-06-08T07:24:32+00:00

Class X -> converted to Y by two ways 1) constructors, and 2) by

  • 0

Class X -> converted to Y by two ways 1) constructors, and 2) by conversion functions.
I understood the single argument constructor is used for conversion.

In the specification:

An implicitly-declared copy constructor is not an explicit constructor; it may be called for implicit type conversion.

Question:

So, that means not only single argument constructor is used for the conversion, but also copy constructor?. If so, which scenario it is used?. any snippet of sample code?

Kindly bear with me if the question is very basis.

  • 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-08T07:24:33+00:00Added an answer on June 8, 2026 at 7:24 am

    Implicitly-declared copy constructor cannot use for conversions, since it’s copy-ctor, that has declared as T(const T&) or T(T&).

    draft n3337 par 12.8 C++ standard.

    8 The implicitly-declared copy constructor for a class X will have the
    form X::X(const X&) if — each direct or virtual base class B of X has
    a copy constructor whose first parameter is of type const B& or const
    volatile B&, and — for all the non-static data members of X that are
    of a class type M (or array thereof), each such class type has a copy
    constructor whose first parameter is of type const M& or const
    volatile M&.119 Otherwise, the implicitly-declared copy constructor
    will have the form X::X(X&)

    Since copy c-tor is not explicit you can use such code

    struct So
    {
    };
    
    int main()
    {
        So s = So();
    }
    

    If copy-ctor is explicit you could use only initizaliation like So s((So()));

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

Sidebar

Related Questions

take two following classes and their constructors as samples: class One{ public: One(int a,int
I have F# class library assembly that contains two functions: let add a b
I get from another class string that must be converted to char. It usually
Why is the Child class's converter constructor called in the code below? I mean,
I am using TimeStamp class to convert seconds into Day,Hours,Minutes,Seconds. I used following code
I'm trying to retrieve a boolean value from one of two member functions. I
I'm using two 3rd party libraries, which both implement their own 2D vector class.
I have two lists user.Roles repository.Roles and RoleViewModel public class RoleViewModel { public int
I would like to implement conversion between two library classes by Convert.ChangeType in C#.
I have two different entities, class Department { int DepID; string DepName; } 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.