我有分配INT问题反对这样的:转换 - 对象为int
int main() {
Wurzel a;
Wurzel b=3; // error: conversion from 'int' to non-scalar type 'Wurzel' requested
return 0;
}
我的类赋值操作符:
class Wurzel{
private:
int wurzelexponent;
int wert;
public:
Wurzel(){
wurzelexponent=1;
wert=1;
}
Wurzel& operator =(const Wurzel &w) {
wurzelexponent = w.wurzelexponent;
}
};
我必须这样做=
运营商
问题在哪里?
不,不是'运营商='但一个构造函数将被调用'吴志祥B = 3;'。 – MikeCAT