Visual C++ doesn't respect the access modifier (protected, or private) for operators that are member function templates.
void operator= (const Y y);
int _tmain(int argc, _TCHAR* argv)
a = 0;
This code fails with the following linker error:
error LNK2019: unresolved external symbol "private: void __thiscall A::operator=<int>(int)" (??$?4H@A@@AAEXH@Z) referenced in function _wmain
Instead, it should fail with a compilation error:
error C2248: 'A::operator =' : cannot access private member declared in class 'A'
This bug can be reproduced in Visual C++ 2005, 2008, and 2010. As a comparison, gcc 4.4.5 is able to detect the error.
IntelliSense in Visual C++ 2010 is able to detect the error:
IntelliSense: "void A::operator=(Y y) [with Y=int]" (declared at line 11) is inaccessible