Hi I have a doubt with a program that I created to still learning c++.
In this program,after a lot of effort, I could do the thing that I wanted.
This thing was to work with a dynamic array but in a function that I made:
1 2 3 4
void crearCentroide(cCentroide* &array){
//...
}
So why have I to use this form of passing the array(cCentroide* &vector)? Otherwise, i hadn'n been able to modify the values of the original vector.
but I don't understand the theory behind this. Thanks a lot. And sorry for my bad english
PD: cCentroide is a class with this definition (i explain it, just in case):
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "centroide.h"
cCentroide::cCentroide() {}
cCentroide::cCentroide(float a, float b) : x(a), y(b){}
void cCentroide::Establecer(float a, float b){x = a, y=b;}
void cCentroide::Leer(float &a, float &b){
a = x;
b = y;
}