मैं जीसीसी के साथ इस कोड संकलन (4.2.1 एप्पल 5664 का निर्माण)अस्पष्ट परिभाषा
#include <cstddef>
using std::size_t;
template <char I> struct index { };
struct a
{
void operator()(size_t const &) { }
};
struct b
{
template <char I>
void operator()(index<I> const &) { }
};
struct c: public a, public b { };
int main (int argc, char const *argv[])
{
c vc;
vc(1);
return 0;
}
और मुझे निम्न त्रुटि दे:
main.cpp: In function ‘int main(int, const char**)’:
main.cpp:22: error: request for member ‘operator()’ is ambiguous
main.cpp:14: error: candidates are: template<char I> void b::operator()(const index<I>&)
main.cpp:9: error: void a::operator()(const size_t&)
मैं डॉन ' यह समझने का कारण क्यों नहीं है कि यह कोड संदिग्ध है; दो तरीकों के अलग-अलग हस्ताक्षर होते हैं।
मुझे आश्चर्य है कि बजना अपने कोड संकलन कर सकते हैं, जबकि जीसीसी की शिकायत:
आप नाम अस्पष्टता दूर करना चाहते हैं आप स्पष्ट रूप से
a::operator()
कॉल कर सकते हैं। – peoro