0

I tried searching about this problem but most questions seem to be the opposite, which is "where did my default constructor go?" Whereas I have the opposite problem and am getting additional overloads that I'm not sure where from. I've tried writing and instantiating the simplest class I can:

class MyClass
{
public:
    MyClass(int)
    {
    }
};

MyClass a(1);

But when I mouse over the class in Visual Studio, or auto-complete pops up, it says I have not 1, but 3 constructor possibilities:

MyClass(const MyClass &&)
MyClass(MyClass &)
MyClass(int)

Obviously this doesn't stop my program from running but is annoying since I'd like any instantiation of MyClass to be forced to provide an int parameter! I'm at a loss where these extra overloads are coming from? If I don't define the constructor then I get no popup at all regarding possible parameters for the class. I've tried moving my class declaration/definition out of MyClass.h and .cpp directly into my main.cpp even to eliminate any possible issue with linking multiple definitions or anything like that, and get the same behavior.

Rushkie
  • 11
  • 1
  • https://stackoverflow.com/questions/66118163/how-to-delete-all-implicit-default-methods-of-class-in-c – Renat Dec 16 '22 at 20:07
  • 1
    These are auto provided by the compiler. See the dupe target for how/when they are generated. – NathanOliver Dec 16 '22 at 20:07
  • Pretty sure that should be `MyClass(const MyClass&)` which is a copy constructor and `MyClass(MyClass&&)` which is a move constructor. – Captain Obvlious Dec 16 '22 at 20:07
  • Thanks all for the help. @CaptainObvlious yes I got those backwards writing them out. Obviously my issue in finding the answer to this myself was not even knowing what move and copy constructors are and that those are the parameters for them! Now I see I can simply define `MyClass(MyClass&&) = delete;` to get rid of them, for anyone that may come across this. – Rushkie Dec 16 '22 at 20:22

0 Answers0