#include <iostream>
using namespace std;
class Complex
{
private:
int real, imag;
public:
Complex(int r = 0, int i =0)
{ real = r; imag = i; }
**friend ostream & operator << (ostream &out, const Complex &c);
friend istream & operator >> (istream &in, Complex &c);**
};
ostream & operator << (ostream &out, const Complex &c)
{
out << c.real;
out << "+i" << c.imag << endl;
return out;
}
istream & operator >> (istream &in, Complex &c)
{ …Run Code Online (Sandbox Code Playgroud) int n = 5;
if(2<=n<=20)
{
cout << "hello";
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,它没有给出错误,它成功运行并且给出“ hello”作为输出。
但是我们必须使用&&这种方程式。
谁能解释一下?