运算符重载的正确用法

#include
using namespace std;

class Complex
{
public:
	int a;
	int b;
	friend ostream& operator<<(ostream &out, Complex c3);
public:
	Complex(int a=0,int b=0)
	{
		this->a = a;
		this->b = b;
	}
	void printfM()
	{
		cout << "a:"<a<<"   b:"<b<< endl;
	}
	Complex operator+ (Complex c)
	{
		Complex tmp(a + c.a, b + c.b);
		return tmp;
	}
};
ostream& operator<<(ostream &out, Complex c3)
{
	out << "a="<

 

你可能感兴趣的:(C++)