#include <iostream>
#include <stdlib.h>
#define Pi 3.14159
using namespace std;
class Rectangle
{
public:
friend ostream &operator<<(ostream &output,const Rectangle &D)
{
output<<"length:"<<D.length<<endl<<"height:"<<D.height<<endl;
return output;
}
friend istream &operator>>(istream &input,const Rectangle &D)
{
input >> D.length >> D.height;
return input;
}
private:
double length;
double height;
};
The error is in [17,19]:no operator ">>" matches these operands -- operand types are: std::istream >> const double
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this. Thank you very much for answering.
Ask yourself, can you read into a const variable? Reading to a variable changes the variable, so the answer is obviously no.
Try this
friend istream &operator>>(istream &input,Rectangle &D)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments