derlemek için başarısız: Ben olsunÇağrı aşağıdaki formu kod parçası ile ilgili bir sorun
:
template<class Type>
class Class1 {
public:
template<class TypeName1> TypeName1* method1() const {return 0;}
};
struct Type1{};
struct Type2{};
class Class2 {
public:
template<typename TypeName1, typename TypeName2>
int method2() {
Class1<TypeName2> c;
c.method1<TypeName1>();
return 0;
}
int method1() {
return method2<Type1, Type2>();
}
};
int
main() {
Class2 c;
return c.method1();
}
CodePad de derleyici ile derlenmiş zaman Aşağıdaki hata:
t.cpp: In member function 'int Class2::method2()': Line 15: error: expected primary-expression before '>' token compilation terminated due to -Wfatal-errors.
Hatalı satır, Şablon üye fonksiyonu:
c.method1<TypeName1>();
İyi cevap. Korkunç bir dil. –
Bir cazibe gibi çalıştı, 5 dakika içinde kabul edecek! –
+1. Özellikle bu bağlamda, 'Class1' ileriye dönük olsa bile, 'Class1 :: method1' şablon işlevidir. Başka bir yerde 'Class1' bir şablon uzmanlaşması aksi kanıtlanabilir. –