binary_function的问题
////////////////////////////////////////////
//
// Compile options needed: /GX
//
// binfunc.cpp : Illustrating the binary_function
// structure.
//
// Structure used: binary_function<A,B,C> - base
// class used to create operator
// functions taking data types A
// and B and returning data type C.
////////////////////////////////////////////
#include <functional>
#include <iostream>
using namespace std ;
class binary_test : public binary_function<binary_test &,int,float>
{
public:
float value;
binary_test(){value=10.0;}
binary_test(float x){value=x;}
result_type operator<<(second_argument_type arg2);
};
binary_test::result_type
binary_test::operator<<(binary_test::second_argument_type arg2)
{
value = ((int)value) << arg2;
cout << "New value after shift is" << value << endl;
return value;
}
void main(void)
{
binary_test item;
cout << "Begin" << endl;
item = item << 2;
///这里item << 2的返回值的类型是float,但这个表达式的左边是binary_test,这里怎么没有编译出错呢?
}