error C2679

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lothas
    New Member
    • Apr 2009
    • 3

    error C2679

    Hi, I'm working on a project to create a robotics simulation environment based on c++ and opengl. Right now I'm stuck trying to solve a compilation error that I'm getting while trying to push_back an object from one of my classes.
    Here's part of the code:
    Code:
    class RobotStruct  
    {
    public:
    	RobotStruct();
    	virtual ~RobotStruct();
    
    	void AddJoint(float Theta, float Alpha, float a, float d, int Type);
    	void PopJoint(int ID) { Joints.erase(Joints.begin()+ID); }
    
    	void DrawRobot();
    
    private:
    	std::vector<RobotJoint> Joints;
    	
    };
    Code:
    class RobotJoint  
    {
    public:
    	RobotJoint();
    	virtual ~RobotJoint();
    	
    	void Set(float _Theta, float _Alpha, float _a, float _d, int _Type);
    
    	void Draw(int ID);
    
    private:
    	int Type;
    	float Theta;
    	float Alpha;
    	float a;
    	float d;
    	Axes JointAxes;
    };
    Code:
    class Axes  
    {
    public:
    	Axes();
    	virtual ~Axes();
    
    	void SetID(char* _ID) { ID=_ID; }
    	char* GetID() const { return ID; }
    
    	void SetOrigin(Vector _Origin) { Origin=_Origin; }
    	void SetOrigin(float _x, float _y, float _z) { Origin.x=_x; Origin.y=_y; Origin.z=_z; }
    
    	void SetAxes(Vector X, Vector Y, Vector Z);
    	void SetAxes(float Xx, float Xy, float Xz, float Yx, float Yy, float Yz, float Zx, float Zy, float Zz);
    
    	void PrintSolid(float Length, float Width, int Resolution, bool OnTop) const;
    	void PrintWire(float Length, float Width, int Resolution, bool OnTop) const;
    
    private:
    	char* ID;
    	Vector Origin;
    	Vector AxisX;
    	Vector AxisY;
    	Vector AxisZ;
    };
    Ok, the error I'm getting is:
    Code:
    c:\program files\microsoft visual studio\vc98\include\xutility(39) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'const class RobotJoint' (or there is no acceptable conversion)
            c:\program files\microsoft visual studio\vc98\include\vector(170) : see reference to function template instantiation 'void __cdecl std::fill(class RobotJoint *,class RobotJoint *,const class RobotJoint &)' being compiled
    when I try to do a push_back here:
    Code:
    void RobotStruct::AddJoint(float Theta, float Alpha, float a, float d, int Type) {
    	RobotJoint Joint;
    	Joint.Set(Theta, Alpha, a, d, Type);
    	Joints.push_back(Joint);
    }
    This used to work properly until I added the class Axes object to the RobotJoint class. Can anyone tell me what am I doing wrong?
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    Your error messages refer to
    line 39 of xutility
    line 170 of vector

    Where do those lines appear in the code excerpts you provided?

    Comment

    • lothas
      New Member
      • Apr 2009
      • 3

      #3
      Those lines would be in the C++ vector class...

      Comment

      • newb16
        Contributor
        • Jul 2008
        • 687

        #4
        looks like robojoint can't be copied:
        Code:
         RobotJoint  a,b;
        a = b;
        Can this be compiled? If not, mostly like because of "Vector Origin;" and other 'Vector' member is Axes. ( Though I have no idea what 'Vector' is)
        And if it can't be copied, it can't be placed in std::vector

        Comment

        • lothas
          New Member
          • Apr 2009
          • 3

          #5
          Exactly. I just managed to solve that today. The RobotJoint class had no problem in being copied as long as it had only floats and chars but when I added an object from Axes class it started complaining.
          I overloaded the = operator for the Axes class and now everything compiles properly.

          Comment

          Working...