I have the following code that is part of an exercise (about which I asked here).
class MyInt
{
public:
MyInt(int x) : MyValue(new int(x)){};
MyInt()
{
MyValue = 0;
}
private:
int* MyValue;
}
int main(int argc,char** argv)
{
MyInt y(1);
MyInt x(y);
.... //Mode code
}
The code compiles and runs (if I didn't forget to put a relevant part of it here). I would like to understand the line
MyInt x(y);
I don't have a constructor that inputs a MyInt, only one that doesn't have parameters and another that inputs an int. The MyInt doesn't have a definition of operator().
What is the computer doing in that line?