« first day (1240 days earlier)      last day (1612 days later) » 

5:01 PM
You guys might have a better answer to this question. ¯\_(ツ)_/¯
 
nwp
I would only add to your answer that they should enable warnings to catch such errors automatically, but I'm too lazy to figure out which warning for which compiler that is.
 
5:23 PM
@nwp Thanks :)
 
nwp
For the record in my opinion it's a bad question that should be sent over to stackoverflow because it's a debugging question where it immediately gets closed for not containing an [mcve]. Might be worth at least commenting about.
 
Yeah.
Hence my comment to my answer "can you reproduce on coliru"
or stacked-crooked. I don't know what's the right name to use.
 
nwp
5:42 PM
Coliru the site, StackedCrooked the guy.
 
Cool!
 
 
5 hours later…
10:44 PM
Date::Date(){
    month = 12;
    day = 30;
    year = 1950;
}
Date::Date(int month, int day, int year){
    this->month = month;
    this->day = day;
    this->year = year;
    self.validate();
}


void Date::validate(){
    if(/*!self.isValid()*/){
        Date();
    }
}
How can I access the current object?
from inside the object
Or is that a no go?
can I just call validate()?
 
@10Replies I guess that the compiler would tell you what's going on and read some basic C++ tutorials to get through this
 
I have
CLion doesn't give me errors for calling validate() and isValid()
so perhaps that may work
Date::Date(){
    month = 12;
    day = 30;
    year = 1950;
}
Date::Date(int month, int day, int year){
    this->month = month;
    this->day = day;
    this->year = year;
    validate();
}

bool Date::isValid(){
    if(month < 1 || month > 12){
        return false;
    }
    if(day < 1 || day > 31){
        return false;
    }
    if(year < 0){
        return false;
    }
    return true;
}
void Date::validate(){
    if(isValid()){
        Date();
    }
}
is this the right way of doing this or is there a better approach stylistically
 

« first day (1240 days earlier)      last day (1612 days later) »