Je dois retourner 3 valeurs. X, Y, Z. J'ai essayé quelque chose comme ça, mais ça ne marche pas, quelqu'un peut-il m'aider un peu? J'ai regardé ici: Return a float array in C++ et j'ai essayé de faire la même chose, sauf avec un tableau de 1 dimension pour revenir.Retour tableau de la classe
class Calculate
{
float myArray[3][4], originalArray[3][4], tempNumbers[4];
float result[3]; // Only works when result is 2 dimensional array, but I need 1 dimension.
public:
Calculate(float x1, float y1, float z1, float r1,
float x2, float y2, float z2, float r2,
float x3, float y3, float z3, float r3)
{
myArray[0][0] = x1;
myArray[0][1] = y1;
myArray[0][2] = z1;
myArray[0][3] = r1;
myArray[1][0] = x2;
myArray[1][1] = y2;
myArray[1][2] = z2;
myArray[1][3] = r2;
myArray[2][0] = x3;
myArray[2][1] = y3;
myArray[2][2] = z3;
myArray[2][3] = r3;
result[0] = 1;
result[1] = 2;
result[2] = 3;
}
float* operator[](int i)
{
return result[i]; //Value type does not match the function type
}
const float* operator[](int i) const
{
return result[i]; //Value type does not match the function type
}
};
Devrait probablement être '& result [i]'. – Archimedix