Good day! I wanted to make a query: I'm new to seeing c ++, but I've seen that when they create objects, when making the constructor by copy, when they define the method, what happens is the memory position of the object they copy, and from there they work with that. I wanted to ask why when it is defined write as if the memory position of the object were passed, instead of passing the object to itself, and then in the main it is shown as if the object itself were passed. For example:
class vector {
private:
float x,y,z;
public:
vector();
vector(float, float, float);
vector(const vector &);
float prim() const;
float seg() const;
float ter() const;
}
vector::vector() {
x = 0;
y = 0;
z = 0;
}
vector::vector(float x2, float y2, float z2) {
x = x2;
y = y2;
z = z2;
}
vector::vector(const vector &v) {
x = v.prim();
y = v.seg();
z = v.ter();
}
float vector::prim() const
{
return x;
}
float vector::seg() const
{
return y;
}
float vector::ter() const
{
return z;
}
int main(){
vector a(4,2,1);
vector b(a);
return 0;
}