C++ 重载运算符函数在';他不是朋友

C++ 重载运算符函数在';他不是朋友,c++,C++,当我的重载插入操作符声明为我的Coord类的朋友时,它可以正常工作。然而,当它不是朋友时,你能向全班展示吗?当它不是朋友时是什么意思?宣布为成员?根本没有申报?以其他方式声明?你需要澄清这一点。你怎么打电话给接线员?你从哪里打电话来的?发一张MCVE。也许您忘记声明运算符了,因为Ori没有声明operator@Shane:如果您只是没有声明它,那么您的代码根本就不会编译。但您声称它输出“垃圾”(意味着它已编译)。这怎么可能? //in my coord.cpp ostream& oper

当我的重载插入操作符声明为我的Coord类的朋友时,它可以正常工作。然而,当它不是朋友时,你能向全班展示吗?当它不是朋友时是什么意思?宣布为成员?根本没有申报?以其他方式声明?你需要澄清这一点。你怎么打电话给接线员?你从哪里打电话来的?发一张MCVE。也许您忘记声明
运算符了,因为Ori没有声明operator@Shane:如果您只是没有声明它,那么您的代码根本就不会编译。但您声称它输出“垃圾”(意味着它已编译)。这怎么可能?
//in my coord.cpp
ostream& operator <<(ostream& outputStream, const Coord &coord_in) {

    outputStream << "( " << coord_in.getRoom() << ", " << 
    coord_in.getRow() << ", " << coord_in.getCol() << " )";   

    return outputStream;
}

//coord.h
#include <iostream>
using namespace std;

#ifndef COORD_H
#define COORD_H

class Coord {
private:
int room;
int row;
int col;
public:
Coord();
Coord(int room_in, int row_in, int col_in);
/* accessor functions */
int getRoom() const;
int getRow() const;
int getCol() const;

/* mutator functions */
void setRoom(Coord coord_in, int newRoom);
void setRow(Coord coord_in, int newRow);
void setCol(Coord coord_in, int newCol);

friend ostream& operator <<(ostream& outputStream, const Coord &coord_in);
};

#endif