如何解决C++中 没有与这些操作数匹配的 "=" 运算符

#include<math.h>
#include "stdafx.h"
#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int main()
{

int b = 5;
int a = 0;

cout << a = ++b + 6;
cout<< endl;
cout << b++ + 6;
cout << endl;
cout << --b;
cout << endl;
cout << --b + 6;

return 0;
}

第1个回答  2019-01-29
void operator=(Set&B)
改成
void operator=(const Set&B)
A+B运算返回的是临时变量,不可以直接引用,要加const引用本回答被网友采纳
相似回答