Here is the code,
Code:
#include <set>

using namespace std;

class A
{
public:
	void bar()
	{
		cout<<"bar"<<endl;
	}
};

void foo(A& a)
{
	a.bar();
}

int main()
{
	set<A> setA;

	A a;
	for(set<A>::iterator it=setA.begin();it!=setA.end();++it)
	{
		a = *it;

		foo(*it);
	}

	return 0;
}
If I call foo(*it), then I get an error " error C2664: 'foo' : cannot convert parameter 1 from 'const A' to 'A &' ". But if I call foo(a), then it would compile just fine. Why? What is the difference between a and *it. I thought they are basically the same. Thanks.