Zebra0.com

cpp dateI am running g++ 4.8.5 on RHEL

I am running g++ 4.8.5 on RHEL

I am running g++ 4.8.5 on RHEL, so some of the date class methods would not compile for me. I like run g++ with the -Wall and -Werror flags as well, which trigger verbose warnings and turn all warnings into errors. This is a personal preference, but also helps me write better code.

I downloaded the code from here http://www.zebra0.com/cpp/classes/date1.php and refactored the Date class to comply with my compiler, which required a few significant changes...

1. _strdate_s does not work with GCC. 

2. Declaring days2 as a static int array in Date.h triggers -Werror. This should be a const int array.

3. The invalid argument exception requires including <stdexcept> in GCC.

4.  Removing some duplicate code.

I've attached my refactors of the class.

date.cpp

date.h

main.cpp

Makefile.txt