I'm with a project where I work with several classes. One of these is the league class which stores different days with dynamic memory. On the other hand I have a case Jornada, it is this I have the following function:
int CJornada::PuntsTotalsJornada(CJornada& jornada)
{
int tmp;
for(int i=0;i<m_numPartits;i++)
{
tmp = jornada.m_partits[i].PuntsTotal();
m_puntsTotalsJornada=m_puntsTotalsJornada+tmp;
}
return m_puntsTotalsJornada;
}
I try to call it from the Liga class with the following function, but I can not get it to work:
void
CLliga::MostraJornadaAmbMesPunts(ostream& os)
{
//os<<"La Jornada amb mes punts es la i amb Puntostotales"<<endl;
for(int i=0;i<m_numJornades;i++)
{
CJornada::PuntsTotalsJornada(m_Jornades[i]);
}
}
It shows me the following error, but I can not think of how to fix it: can not call member function int CJornada::PuntsTotalsJornada(CJornada&)
without object
This would be the league builder:
CLliga::CLliga()
{
// Estableix el valor per defecte de les variables de CLliga
m_nomLliga = ("????");
m_temporada = ("0000-0000");
m_Jornades = 0;
m_numJornades = 0;
}
And its attributes:
private:
CCadena m_nomLliga;
CCadena m_temporada;
CJornada *m_Jornades;
int m_numJornades;
I add that the attribute M_Jornades
is a list of days that contains attributes such as the number of matches, attached its constructor and attributes to clarify:
CJornada::CJornada()
{
// Defineix aqui el constructor per defecte
m_partits = 0;
m_numPartits = 0;
m_idJornada = 0;
m_puntsTotalsJornada=0;
}
private:
CPartit *m_partits;
int m_numPartits;
int m_idJornada;
int m_puntsTotalsJornada;