当前位置:网站首页>关于重载运算符的再整理
关于重载运算符的再整理
2022-07-01 14:36:00 【团团带你学代码】
#include<iostream>
using namespace std;
class a
{
public:
a(int year1,int month1,int day1){year=year1;month=month1;day=day1;}
friend ostream&operator <<(ostream&output,a&b);
private:
int year,month,day;
};
ostream&operator <<(ostream&output,a&b)
{
output<<b.year<<"年"<<b.month<<"月"<<b.day<<"日";
return output;
}
int main()
{
a b(2022,6,29);
cout<<b;
}
可以结合有参构造函数,直接传递参数进行构造有关函数。

边栏推荐
- C#学习笔记(5)类和继承
- Use the npoi package of net core 6 C to read excel Pictures in xlsx cells and stored to the specified server
- Build your own website (21)
- How will the surging tide of digitalization overturn the future?
- MIT team used graph neural network to accelerate the screening of amorphous polymer electrolytes and promote the development of next-generation lithium battery technology
- 用对场景,事半功倍!TDengine 的窗口查询功能及使用场景全介绍
- Phpcms realizes the direct Alipay payment function of orders
- After being laid off for three months, the interview ran into a wall everywhere, and the mentality has begun to collapse
- sqlilabs less-8
- Leetcode (69) -- square root of X
猜你喜欢

241. 为运算表达式设计优先级

643. Maximum average number of subarrays I

241. Design priorities for operational expressions

深度合作 | 涛思数据携手长虹佳华为中国区客户提供 TDengine 强大企业级产品与完善服务保障

Use the npoi package of net core 6 C to read excel Pictures in xlsx cells and stored to the specified server

Phpcms realizes the direct Alipay payment function of orders
![[IOT design. Part I] stm32+ smart cloud aiot+ laboratory security monitoring system](/img/a0/2654d43cfb6a135cc15d84447a13f9.png)
[IOT design. Part I] stm32+ smart cloud aiot+ laboratory security monitoring system
![[15. Interval consolidation]](/img/6c/afc46a0e0d14127d2c234ed9a9d03b.png)
[15. Interval consolidation]

sqlilabs less-11~12

How can we protect our passwords?
随机推荐
JVM performance tuning and practical basic theory part II
"National defense seven sons" funding soared, with Tsinghua reaching 36.2 billion yuan, ranking second with 10.1 billion yuan. The 2022 budget of national colleges and universities was made public
sqlilabs less9
After being laid off for three months, the interview ran into a wall everywhere, and the mentality has begun to collapse
Admire, Ali female program undercover more than 500 black production groups
sqlilabs less13
30 Devops interview questions and answers
One of the data Lake series | you must love to read the history of minimalist data platforms, from data warehouse, data lake to Lake warehouse
Research Report on the development trend and competitive strategy of the global pipeline robot inspection camera industry
[getting started with Django] 13 page Association MySQL "multi" field table (check)
[IOT completion. Part 2] stm32+ smart cloud aiot+ laboratory security monitoring system
Basic concepts of programming
如何看待国企纷纷卸载微软Office改用金山WPS?
Guess lantern riddles, not programmers still can't understand?
[R language data science]: common evaluation indicators of machine learning
Basic operation of queue (implemented in C language)
sqlilabs less13
Phpcms realizes the direct Alipay payment function of orders
Research Report on the development trend and competitive strategy of the global aviation leasing service industry
TexStudio使用教程