Apologies in advance for this question. It's been awhile since I've used C++ and I can't seem to find an exact tutorial that answers my question. I think this is an example of implicit conversion, but I'm not sure.
Code:
class Square
{
public:
Square(int size) : size{size}
{
}
int getSize() const
{
return size;
}
private:
int size;
};
void doSomething(Square square)
{
cout << "doSomething called with " << square.getSize() << endl;
}
int main()
{
// Should be passing in a Square type here, but instead passing an int.
doSomething(23);
return 0;
}
Output:
doSomething called with 23
Questions:
- Is this an example of implicit conversion?
- How is this occurring? I'd be satisfied with a link that explains this in more detail. For what it's worth, I've already gone over the cplusplus.com explanation of Type conversions.
Thank you!