Hello I have a simple question: If I have a class that has a constructor that takes an integer for example then if I copy-initialize an object of that class then is copy-constructor or constructor is called:
class M
{
public:
M(int) { cout << "M(int)\n"; }
M(const M&) = delete;
M(const M&&) = delete;
};
int main()
{
M m = 9; // why M(int) is called but not a copy-ctor or move-ctor?
}
- AS you can see I have an ambiguity here:
M m = 9;
I think it is a form ofCopy-initialization
so normally I think the copy-ctor or move-ctor should be called. I've declared theme deleted to get an compile-time error but it works?