Garbage values in my methods?

Hello everybody, just for a little background I have almost no experience in Object Oriented Design, so this may seem like a simple error but I've fuddled around with different ideas for hours and cannot seem to come to a solution.

In the "MMDDYYYY" method, I have formatted output to display a date in MMDDYYYY format. Here is the method here:

1
2
3
4
5
6
7
void Date::MMDDYYYY()
{
    int MM = getMonth();
    int DD = getDay();
    int YYYY = getYear();
    cout << MM << "/" << DD << "/" << YYYY;
}  


I've tested using just:

1
2
3
4
void Date::MMDDYYYY()
{
    cout << getMonth() << " " << getDay() << " " << getYear();
}


But that didn't work either.

In main, I use the mutator setYear(int) to try to make the private member in the Date class 1997:

1
2
3
cout << "Please enter the year in YYYY format: ";
cin >> yearChoice;
date.setYear(yearChoice);


But, when given the value '1997', it returns a value of
6422368


If I haven't given enough information, just let me know and I'll be more than happy to elaborate even further. Cheers!
Last edited on
We need to see the whole program. Anything could be happening.
Topic archived. No new replies allowed.