I'm working on C++, and had an error that I didn't know the exact reason. I've found the solution, but still want to know why.
class Base
{
public:
void something(Base& b){}
};
int main()
{
Base b;
b.something(Base());
return 0;
}
when I compile the code, I got this following error :
abc.cpp:12:20: error: no matching function for call to ‘Base::something(Base)’
abc.cpp:12:20: note: candidate is:
abc.cpp:6:7: note: void Base::something(Base&)
abc.cpp:6:7: note: no known conversion for argument 1 from ‘Base’ to ‘Base&’
but when I replaced b.something(Base()) into
Base c;
b.something(c);
the error is gone, I'm wondering why??? aren't they have the same type? It only matters how I write it, but the meaning should be the same???
Thanks Guys!