freeflywyx 发表于 2008-6-25 10:42

类的构造问题

class vector3m:public point3d,public vector3d
{
public:
        int id;
        point3d stress;
        vector3d v_max,v_mid,v_min;
    int z_style;
        point3d p0,p1,p2,p3,p4,p5,p6,p7;
public:
        vector3m(){}

        vector3m(int id,
                     double stress_max,double stress_mid,double stress_min,
                         double v_maxx,double v_maxy,double v_maxz,double v_midx,double v_midy,double v_midz,double v_minx,double v_miny,double v_minz,
                         int z_style,
                         double p0x,double p0y,double p0z,/*0 1 2 4是z=0面点*/
                         double p1x,double p1y,double p1z,
                         double p2x,double p2y,double p2z,
                         double p3x,double p3y,double p3z,
                         double p4x,double p4y,double p4z,
                         double p5x,double p5y,double p5z,
                         double p6x,double p6y,double p6z,
                         double p7x,double p7y,double p7z)
        {
                stress.point_set(stress_max,stress_mid,stress_min);
                v_max.vector_set(v_maxx,v_maxy,v_maxz);
                v_mid.vector_set(v_midx,v_midy,v_midz);
                v_min.vector_set(v_minx,v_miny,v_minz);
                p0.point_set(p0x,p0y,p0z);
                p1.point_set(p1x,p1y,p1z);
                p2.point_set(p2x,p2y,p2z);
                p3.point_set(p3x,p3y,p3z);
                p4.point_set(p4x,p4y,p4z);
                p5.point_set(p5x,p5y,p5z);
                p6.point_set(p6x,p6y,p6z);
                p7.point_set(p7x,p7y,p7z);
                this->id=id;
                this->z_style=z_style;
   }

        vector3m(vector3m & v2)
    {
                id = v2.id;
                stress = v2.stress;
                v_max = v2.v_max;
                v_mid = v2.v_mid;
                v_min = v2.v_min;
                z_style = v2.z_style;
                p0 = v2.p0;
        p1 = v2.p1;
                p2 = v2.p2;
                p3 = v2.p3;
                p4 = v2.p4;
                p5 = v2.p5;
                p6 = v2.p6;
                p7 = v2.p7;                       
        }

        vector3m& operator =(vector3m v1)
        {
                this->stress = v1.stress;
                this->v_max = v1.v_max;
                this->v_mid = v1.v_mid;
                this->v_min = v1.v_min;
                this->p0 = v1.p0;
        this->p1 = v1.p1;
                this->p2 = v1.p2;
                this->p3 = v1.p3;
                this->p4 = v1.p4;
                this->p5 = v1.p5;
                this->p6 = v1.p6;
                this->p7 = v1.p7;
                this->id=v1.id;
        this->z_style=v1.z_style;
                return *this;
        }
};
编译的时候怎么还提示:没有可用的复制构造函数或者复制构造函数声明为“explicit”
请问如何解决这个问题?
谢谢先

freeflywyx 发表于 2008-6-25 11:19

我定义了一个函数需要返回这个类
vector3m id_infor(/*参数表*/){}

zjl138 发表于 2008-6-25 11:53

class vector3m:public point3d,public vector3d{ ........}


你有没有为你的 point3d,vector3d定义复制构造函数?

freeflywyx 发表于 2008-6-25 15:21

呵呵
都有了
问题也解决了
vector3m(const vector3m & v2){}
加了const就编译通过了
谢谢zjl138 的帮忙

页: [1]

编程论坛