I have the CClass class
//clase.h
class CClass{
public:
int suma (int X, int Y);
private:
int X;
int Y;
}
//clase.cpp
//constructor aqui
int
CClass::suma(intX, int Y){
int resultado = 0;
resultado = X + Y;
return resultado;
}
And in main.cpp I have created a block of memory with several objects of the class CClass with the help of a for and a pointer
//main.cpp
ifstream fitxer(fichero);
if (fitxer.is_open())
{
int = 0;
delete[] m_Clase; //m_Clase es un apuntador al objeto de la clase declarado en main.h
m_Clase = new CClass [10]; //reservo un bloque de memoria para 10 objetos CClass
for (i=0; i<10; i++){
is >> m_Clase[i];
}
fitxer.close();
}
Now I want to include a function in main.cpp to add the result of all the 'sum' functions of the different CClass objects
int suma total(/*???*/){
int total = 0;
//total = suma() + suma() + suma ()... etc
}
But I have no idea what variables I have to pass or how to complete it.