我们如何重载运算符<<在C ++中? [英] how can we overload operator << in c++ ?

查看:121
本文介绍了我们如何重载运算符<<在C ++中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How can we overload << operator in c++ if we want to add two numbers with the help of this operator?

推荐答案

这是一个太特殊的问题,无法真正有用.您需要学习所有C ++语言本身,而不是解决类似的单独问题.首先,您需要尝试自己动手做,并且仅在遇到问题无法使用C ++手册/参考以及Google的帮助时才能提出问题.

在这种情况下,这应该对您有帮助(例如):
http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html [ ^ ].

更好的是,请访问C ++手册.你用什么吗?

—SA
This is a too particular question to be really useful. You need to learn all the C++ language itself instead of addressing separate problems like that. First of all, you need try to do it yourself, and only ask a question when you face a problem you cannot resolve using C++ manual/reference and the help if Google.

In this case, this should help you (for example):
http://www.cs.caltech.edu/courses/cs11/material/cpp/donnie/cpp-ops.html[^].

Better yet, address to C++ manual. Do you use any?

—SA


在技术上可行的情况下,这会误导使用运算符重载.
While technically possible, that would be a misleading use of operator overloading.


您可以使用此链接以下.希望这能解决您的问题...

使用C ++运算符重载来创建简单的分数类 [
You can use this link below. Hope this will solve your problem...

Using C++ operator overloading to make a simple fraction class[^]


这篇关于我们如何重载运算符&lt;&lt;在C ++中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆