vendredi 19 mars 2021

Valgrind error: Conditional Jump or move depends on uninitialised values

I'm new to code testing and in my college I'm asked to use valgrind to check my code and it shows me this error:

Conditional jump or move depends on uninitialised value(s) ==1036269== at 0x10A745: Fecha::Fecha(int, int, int) (in /home/poo/Escritorio/Proyectos- universidad/POO/P0/main) ==1036269== by 0x10A60B: main (in /home/poo/Escritorio/Proyectos-universidad/POO/P0/main)

Main.c:

#include <iostream>
#include "fecha.hpp"
#include "cadena.hpp"
#include <ctime>
using namespace std;//Avoid using std:: ....

int main(){
   Fecha a,b(3,3,2000),c(b);
   c.show_date();
   return 0;
}

fecha.hpp (Definition in the header file)

Fecha(int d, int m, int y);

fecha.cpp (Implementation):

Fecha::Fecha(int d,int m,int y){

if (day == 0 && month ==0 && year==0)
{
    Fecha aux;
    this->day=aux.dia();
    this->month=aux.mes();
    this->year=aux.anno();
}
if (Fecha_check(d,m,y)=="ok"){
    day=d;
    month=m;
    year=y;
}        
};

Pls don't be hard with me =)

Aucun commentaire:

Enregistrer un commentaire