P222 _()运算符重载

#include <iostream>
using namespace std;

class F
{
public:
	int operator()(int a, int b)
	{
		return (a*a + b*b);
	}

	

};

class F2
{
public:
	int MemFunc(int a, int b)
	{
		return a*a + b*b;
	}
};

int main()
{
	F f;
	f(2,4);

	//()重载同函数调用的区别
	F2 f2;
	f2.MemFunc(2,4);

	//
	//operator()(int a,int b)
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_41983807/article/details/87826836