C++ Error: no match for call to '(Vector3 (double, double, double)' -


so i'm having error prevents me continuing assignment.
here code:

#include "std_lib_facilities.h"  class vector3 { public:     vector3();     vector3(double x1);     vector3(double x1, double y1);     vector3(double x1, double y1, double z1);  //helper functions     double x() {return x1;}     double y() {return y1;}     double z() {return z1;}   private:     double x1,y1,z1; };  /** constructor definitions **/ vector3::vector3(double x, double y, double z){     x1=x;     y1=y;     z1=z; } vector3::vector3(double x, double y){     x1=x;     y1=y; } vector3::vector3(double x){     x1=x; } vector3::vector3() {     x1=0;     y1=0;     z1=0; }  /** operator overloading **/  ostream& operator<<(ostream&os, vector3& v) //<< overloading  {     return os <<"["<<v.x()               <<", "<<v.y()               <<", "<<v.z()               <<"]"<<endl; }  vector3 operator+(vector3 v1, vector3 v2) //+ overloading {     double a,b,c;     vector3 vector1(a,b,c);     return vector1( v1.x()+v2.x() , v1.y()+v2.y() , v1.z()+v2.z() ); } 

this header file. error happens @ //+overloading ( last bit of code) @ return line.
googled no avail. people suggesting i'm using function or variable has same name else can't find that.

vector3 vector1(a,b,c);     return vector1( v1.x()+v2.x() , v1.y()+v2.y() , v1.z()+v2.z() ); 

first you're constructing vector3 object using uninitialized variables. you're trying invoke call operator (operator()) on object. operator+ function should this:

vector3 operator+(vector3 v1, vector3 v2) //+ overloading {     return vector3( v1.x()+v2.x() , v1.y()+v2.y() , v1.z()+v2.z() ); } 

Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -