Digression: get the current local date and time in C++

  1. time.C. The function localtime fills up a structure with information, and returns a pointer to this structure.
    (tm_sec might be a leap second.)

Create a C++ class

Pass some information down to three functions (print, next, and next) that do all the work.

  1. 3ints.C. Hold the information about a date in three ints.
  2. struct.C. Hold the information about a date in one struct.
  3. Hold the information about a date in one object.
    1. obj1.C. An object with data members and (non-static) member functions
    2. obj2.C. Add a constructor and a static data member.
      Make the data member private.
      Exercise.
      Now that we have a constructor that throws exceptions, what would happen if the main function tried to create a
      	date d {2, 30, 2025};   //Bad date: there is no Ferbruary 30
      
      Can you catch the exception?
    3. Separate header and implementation files.
      #include with "double quotes" looks in your current directory for the header file.
      #include with <double quotes> looks in the directory /usr/include/c++/14 for the header file (on our machine storm.cis.fordham.edu).
      Compile this three-file program (consisting of date.h, date.C, main.C) with
      c++ main.C date.C
      
      1. date.h. The header file for class date.
      2. date.C. The implementation file for class date.
      3. main.C. A C++ program that uses objects of class date.
      4. main2.C. Another C++ program that uses objects of class date.

        Compile this three-file program (consisting of date.h, date.C, main2.C) with
        c++ main2.C date.C
        

Class stack

  1. last semester’s stack example
  2. An object that holds a stack of ints:
    1. stack.h
    2. stack.C
    3. main.C
  3. Don’t build your own: the C++ Standard Library already has a class stack.

Class rand