0
이 궁금 언어 기능 또는 컴파일러의 버그 :이상한 그림자는 4.7.2
#include <iostream>
template<class T>
class A{
public:
virtual void func(T const & x)
{ std::cout << "A func: " << x << "\n"; }
void func(T const &x, T const & y)
{ std::cout << "Double func:\n";
func(x); func(y);
}
};
template<class T>
class B : public A<T>{
public:
virtual void func(T const & x)
{ std::cout << "B func: " << x << "\n"; }
};
int main(){
A<int> a;
a.func(1);
a.func(2,3);
B<int> b;
b.func(1);
b.func(2,3);
}
두 a.func (1) 및 a.func (2,3)가 제대로 작동합니다. 그러나 b.func (2,3)이 생성
그것은 그림자 호출되지 것3.c++: In function ‘int main()’:
3.c++:27:13: error: no matching function for call to ‘B<int>::func(int, int)’
3.c++:27:13: note: candidate is:
3.c++:20:16: note: void B<T>::func(const T&) [with T = int]
3.c++:20:16: note: candidate expects 1 argument, 2 provided