Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 错误C2582:&x27;运算符=';功能在中不可用_C++_Compiler Errors - Fatal编程技术网

C++ 错误C2582:&x27;运算符=';功能在中不可用

C++ 错误C2582:&x27;运算符=';功能在中不可用,c++,compiler-errors,C++,Compiler Errors,我有课 class Points { public: Points(); } 还有一个, class OtherPoints : public Points { public: OtherPoints (); Points myPoints; } 现在在OtherPoints()构造函数中,我试图创建一个Point变量 OtherPoints::OtherPoints(){ myPoints=Points(); } 然后得到错误 错误C2582:“运算符=”函数在“点

我有课

class Points
{
 public:
 Points();
}
还有一个,

class OtherPoints : public Points
{
 public:
 OtherPoints ();

 Points myPoints;
}
现在在
OtherPoints()
构造函数中,我试图创建一个
Point
变量

OtherPoints::OtherPoints(){ 
    myPoints=Points();
}
然后得到错误

错误C2582:“运算符=”函数在“点”中不可用


我不认为
myPoints=Points()是必需的

Points myPoints; // This code has already called the constructor (Points();)

这是我编译的代码,它编译得非常好

 #include<iostream>
 using namespace std;
 class points{
    public: points(){cout<<"constructor points called"<<endl;}
            virtual ~points(){cout<<"destructor points called"<<endl;}
 };
 class otherpoints: public points{
                    points x1;
    public: otherpoints(){cout<<"constructor otherpoints called"<<endl;x1=points();}
            ~otherpoints(){cout<<"destructor otherpoints called"<<endl;}
 };
 int main(int argc, char *argv[])
 {
    otherpoints y1=otherpoints();        
    return 0;
 }
#包括
使用名称空间std;
班级积分{

public:points(){coutDefault赋值运算符应该可用。这是完整的代码吗?顺便说一句,类定义末尾缺少
。修复缺少的
(有两个),可以发布真实的代码吗?a会很有帮助。仅供参考,赋值操作本身是无用的。您的
myPoints
已经构建得非常好了。