小编Ahm*_*nan的帖子

运算符 <<(操作数类型 std::ostream)不匹配 C++ OOP 和 Point

我正在尝试显示我通过成员函数创建的 Point 类的 p 对象。我已将 Point p 作为参数传递给我的程序的 void displayPoint(Point p) 成员函数。但是我的程序中出现以下编译错误!

D:\OOP 赋值 #01\point.cpp[Error] 没有匹配 'operator<<'(操作数类型是 'std::ostream {aka std::basic_ostream}' 和 'Point')

下面是我的代码!!!

#ifndef POINT_H
#define POINT_H

using namespace std;     // For string usage

class Point
{
public:
    Point();                                    // Default Constructor
    Point(double, double, int);                // Three argument constructor
    void initialize(double, double, int);    
    void shift(Point p, int keyPress);                      // Shift the first point 

    void setValue(int value);
    int getValue() const;
    void setX();
    double getX() const;
    void setY();
    double gety() const;

    void …
Run Code Online (Sandbox Code Playgroud)

c++ oop c++11

5
推荐指数
1
解决办法
9万
查看次数

标签 统计

c++ ×1

c++11 ×1

oop ×1