template<class argument1, class argument2, class result>
class binary_function{
public:
typedef argument1 first_argument_type;
typedef argument2 second_argument_type;
typedef result result_type;
};
class cmplxData : binary_function<double, double, int>{
public:
result_type operator()(first_argument_type t1, second_argument_type t2){
return (result_type)(t1+t2);
}
};
int main(int argc, char *argv[]){
return 0;
}
拋出下面的錯誤下面輸入的代碼不編譯
error: reference to ‘binary_function’ is ambiguous prog18.cpp:38:34: error: expected template-name before ‘<’ token class cmplxData : binary_function{
^prog18.cpp:38:34: error: expected ‘{’ before ‘<’ token prog18.cpp:38:34: error: expected unqualified-id before ‘<’ token
[無法重現](http://coliru.stacked-crooked.com/a/d51c560a75013858)。 – Angew
這款編譯器適合VS2015。什麼編譯器和你使用什麼標誌? –
38行應該在你的17行代碼中?請提供[MCVE] – muXXmit2X