Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 396 Bytes

15.2_左移运算符重载.md

File metadata and controls

34 lines (22 loc) · 396 Bytes
class MyInteger
{
	friend  ostream& operator<<(ostream& out, const MyInteger& p);

private:
	int sex;

public:
	int num;

	MyInteger(int num) :num(num) {
		sex = 100;
	};


};

ostream& operator<<(ostream& out, const MyInteger& p) {
	return	cout << "num:"  << p.num << '\t' << "sex:" << p.sex;
}

int main() {

	MyInteger p = 10;

	cout << p << endl;


	system("pause");

	return 0;
}