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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:04:33+00:00 2026-05-23T07:04:33+00:00

I have these codes: class Type2 { public: Type2(const Type1 & type); Type2(int); const

  • 0

I have these codes:

class Type2 {
public:
  Type2(const Type1 & type);
  Type2(int);
const Type2 & operator=(const Type2 & type2);
//....
};

...
  Type1 t1(13);
  Type2 t2(4);

  t2=t1;

As I understood, the 1-argument constructors of Type2 each without an explicit keyword should mean any Type1 objects or int values can be implicitly conveted to Type2 objects.

But in the last line t2=t1;, MS Visual Studio gives me this compile error:

….error C2679: binary ‘=’ : no operator
found which takes a right-hand operand
of type ‘Type1’ (or there is no
acceptable conversion)….

Seems like MS Visual Studio insisting t2=t1; must match an assignment operator with lhs=Type2 and rhs=Type1. Why can’t it implicitly cast rhs to t2 and then do the copying with the Type2=Type2 operator?

  • 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-05-23T07:04:34+00:00Added an answer on May 23, 2026 at 7:04 am

    I’ve found the answer. Because my Type1 got a conversion operator

        class Type1 {
        public:
            Type1 (int );
            operator  Type2() ;//casting to Type2
    
        ....
        };
    

    This is something called “dual-direction implicit conversion”

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

Sidebar

Related Questions

So I have this code for these Constructors of the Weapon class: Weapon(const WeaponsDB
I have a class : Schedule. public class Schedule { private int locationNum; private
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
I have these two pieces of code, wich one is more readable? foreach decimal
I have seen code around with these two styles , I am not not
When I compile the following code using g++ class A {}; void foo(A&) {}
I have a questing around such staff. There is a class A which has
Imagine I have a class used to represent some trivial numerical data, like a
This question is best described in code. I have a class called Vertex that
I have a CacheHelper class to facilitate interaction with the cache. I want to

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.