腾讯云
开发者社区
文档
建议反馈
控制台
首页
学习
活动
专区
工具
TVP
最新优惠活动
文章/答案/技术大牛
搜索
搜索
关闭
发布
登录/注册
精选内容/技术社群/优惠产品,
尽在小程序
立即前往
文章
问答
(9999+)
视频
沙龙
4
回答
为什么在某些情况下使用friend
operator
<<,而在其他情况下不使用
c++
、
operator-overloading
、
member
我
都看过了
ostream&
operator
<<(
ostream&
stream, Complex z) (即
成员
函数)
我
很难明白什么时候应该排除朋友,什么时候包括朋友才是重要
的
。
我
的
理解是:<
浏览 4
提问于2019-03-18
得票数 2
2
回答
为什么要使用朋友函数?
c++
、
friend
我
试图用同样
的
方法重载运算符'=‘和'<<’。 public:
ostream&
operator
<<(
ostream&
out, const Vect& vect); //..错误'std::
ostream&</em
浏览 4
提问于2015-11-17
得票数 1
0
回答
cout如何调用
类
的
私有
成员
c++
、
oop
、
g++
: r = 10.5; }}; write << comp.r << ": " &l
浏览 6
提问于2017-01-01
得票数 1
回答已采纳
2
回答
用于输出流运算符
的
朋友函数显示错误,因为无法
访问
c++
、
friend
我
已经在文件VRKVector.h中编写了如下简单
的
类
class VRKVector { std::vector<int> m_coordinates* @return none. friend std::
ostream&
operator
<< (std::
ostream&
out, vrk::VRKVector&
operator</e
浏览 3
提问于2020-07-15
得票数 0
3
回答
operator
<<不匹配
c++
、
stream
、
operators
我
有一个这样
的
代码片段: unsigned minutes, seconds; o << minutes << "minute(s) " << seconds << " second(s)";std
浏览 0
提问于2012-11-25
得票数 1
回答已采纳
1
回答
ostream&
operator
<<
声明
不允许
我
访问
类
的
私有
成员
c++
、
namespaces
、
operator-overloading
我
有以下
类
声明
: #ifndef ANIL_CURSOR_LIST_H#include <iostream==(cursor_list& rhs); // rhs = right hand side
浏览 16
提问于2021-07-09
得票数 1
回答已采纳
6
回答
运算符<<与继承/组合
c++
、
overloading
、
operator-keyword
我
发现自己在尝试正确重载
operator
<<时遇到了一些麻烦。
我
已经搜索过关于它
的
其他问题,但是似乎没有一个答案适合这个问题,所以这里是:
我
有一个
类
(寄存器)存储另一
类
的
样本(电影
的
子类,它是抽象
的
)。重载
的
寄存器操作符<<应该将存储在每个Film元素中
的
所有数据通过ostream
类
放到屏幕上。){ for(int i=0;i<
浏览 12
提问于2014-05-15
得票数 0
回答已采纳
2
回答
为什么
我
不能在
operator
<<中
访问
类
Box
的
私有
成员
?
c++
、
class
、
private
、
operator-keyword
、
iostream
为什么
我
不能在Box中
访问
ostream&
operator
<<(
ostream&
out, const Box& B){cout << B.l << " " << B.b << " " << B.h<< endl; }中
的
私有
函数using names
浏览 2
提问于2022-06-16
得票数 1
回答已采纳
2
回答
在<<中重载C++操作符需要朋友
c++
、
operator-overloading
+(const Vector2& other) const; friend
ostream&
operator
<< (
ostream&
stream, const Vector2& other);};
ostream&
浏览 3
提问于2021-06-19
得票数 0
回答已采纳
1
回答
从文件中读取对象
的
c++编译错误
c++
、
file
、
templates
、
stream
我
将对象保存到文件中,在读取对象时,
我
希望将其内容写入输出流。
我
确实为它添加了操作符重载,friend std::
ostream&
operator
<<(std::
ostream&
out, T& c),但是如何正确地做它呢?IFileClass<T>(fn) {
浏览 4
提问于2020-08-05
得票数 1
回答已采纳
2
回答
流插入/提取操作符重载函数
的
原型属于哪里?
c++
、
operator-overloading
假设它们不是作为friend函数实现
的
。{};class Foo};为什么?
浏览 0
提问于2013-04-28
得票数 0
回答已采纳
1
回答
非
成员
函数需要通过指针打印数组。
c++
、
arrays
、
pointers
我
需要编写一个矩阵
类
,它有一个指向双重数组
的
指针。
我
要把这些双打印在“矩阵路”上。
我
创建了一个
私有
的'double *m‘,它引用一个数组(参见构造函数)。现在,
operator
<<是一个非
成员
函数,
我
不知道如何打印指针指向
的
数组。=(const Matrix& matrix); friend con
浏览 4
提问于2015-08-14
得票数 2
回答已采纳
1
回答
是否继承了非
成员
友元函数重载运算符?
c++
、
inheritance
、
operator-overloading
、
friend
我
有
我
的
父
类
B,并且
我
重载了<<操作符。
我
的
派生
类
D似乎可以使用这个运算符,尽管我到处都能读到
类
不从父
类
继承friend函数。顺便说一句,
我
使用了公共继承。
我
很困惑。之所以这样做,是因为它是一个重载运算符,或者任何友元函数都是由子级继承
的
。另外,如果它们是继承
的
,
我
可以以任何方式重新定义它们吗?
浏览 31
提问于2021-02-06
得票数 1
3
回答
运算符重载
的
friend关键字
c++
我
试着为<<-
operator
-overloading写一个简单
的
例子。以前,
我
从来没有用过“朋友”这个关键词。但没有它,它就不能工作。
我
做错了什么,或者为什么
我
需要在这里
的
朋友关键字?class rational{ rational(double num, double count) rational&
operator
+=(const rational&am
浏览 28
提问于2016-07-28
得票数 3
回答已采纳
2
回答
在模板链表中使用好友函数时出现链接错误
c++
、
templates
、
linked-list
、
linker-errors
、
friend
我
编写了一个模板链表(在.h文件中),
我
得到了链接错误。&
operator
<< (
ostream&
out, const LinkedList<T>& that); const T*
operator
template <typename T>
ostream&
operator
<< (
ostr
浏览 0
提问于2011-12-17
得票数 3
回答已采纳
1
回答
跨多个文件
的
朋友函数
c++
、
function
、
overloading
、
operator-keyword
、
friend
我
已经将
operator
<<函数
声明
为.h文件中
类
的
朋友,但仍然不能
访问
.cpp文件中函数定义中
的
私有
成员
变量Test.h{ intsize; friend
ostream&
operator
<< (ostream &out, Tes
浏览 2
提问于2014-04-04
得票数 1
回答已采纳
2
回答
如何重载<<运算符以输出作为
类
成员
的
向量
c++
、
class
、
vector
、
overloading
我
尝试使用<<运算符来输出作为
我
的
类
的
私有
成员
的
向量。如何让<<操作符输出
私有
成员
向量
的
所有内容?这是
我
<
浏览 3
提问于2013-11-16
得票数 2
2
回答
无法
访问
friend
类
的
私有
成员
c++
、
header
、
private
、
friend
我
有一个
类
的
形状。Shape需要使用class Center
的
私有
数据
成员
,x和y坐标。
我
声明
friend
类
Shape;然后#include "center.h“in Shape.h。在Shape.cpp中,
我
定义了
ostream&
operator
<< (
ostream&
ostr,const Center& c)函
浏览 2
提问于2013-03-01
得票数 1
回答已采纳
4
回答
C++如何编写不是
成员
函数
的
运算符?
c++
有谁知道如何为不是
类
的
成员
函数
的
类
编写运算符?
浏览 0
提问于2011-07-10
得票数 1
回答已采纳
2
回答
实现重载运算符'<<‘- C++时出错
c++
、
overloading
、
operator-keyword
我
目前正在尝试重载'<<‘操作符,但是一直收到以下错误消息: 在函数'std::
ostream&
operator
<<( std::
ostream&
,const : Linkedlist&)中: Linkedlist.cpp:148:34: Linkedlist.cpp:148:34:std::
operator
<< <<中
的
'
operator
<<‘没有匹
浏览 4
提问于2012-08-26
得票数 0
点击加载更多
扫码
添加站长 进交流群
领取专属
10元无门槛券
手把手带您无忧上云
相关
资讯
Kotlin里的类、对象和接口
Python笔记
Python 类的私有成员
设计模式学习心得——(二)单例模式
关于JAVA你必须知道的那些事(三):继承和访问修饰符
热门
标签
更多标签
活动推荐
运营活动
广告
关闭
领券