Thread: Create a class called date and a child class called time

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    1

    Create a class called date and a child class called time

    Hello everyone, I am trying to learn c++ and I am having a very hard time understanding this problem.

    I am supposed to create a class called date that has the following requirements:

    3 constructors
    1 destructor
    getMonth
    getDay
    getYear
    setMonth
    setDay
    setYear
    A function print with no arguments
    An equality overload
    An assignment overload
    A copy constructor

    For the child time it must have

    3 constructors
    1 destructor
    getHours
    getMinutes
    getSeconds
    setHours
    setMinutes
    setSeconds
    A function print with no arguments
    An equality overload
    An assignment overload
    A copy constructor

    I know how to do do the simple code like getHours or getDate or setHours etc. However, I am not exactly sure where to go for the 3 constructors, equality overload, assignment overload and the copy constructor. If anyone can point me in the right direction I would appreciate it. Thanks

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    San Jose
    Posts
    2,633
    > 3 constructors:
    Make them take different formats of date/times.

    > equality/assignment overload:
    Operator Overloading in C++ - Cprogramming.com

    > copy constructor
    Copy constructor - Cprogramming.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sleep(1) takes longer each time it is called?
    By lsad in forum C Programming
    Replies: 13
    Last Post: 07-08-2010, 02:28 AM
  2. Help with using c++ class called with P/Invoke
    By dudeomanodude in forum C# Programming
    Replies: 2
    Last Post: 05-10-2009, 12:38 AM
  3. Incrementing a number each time a function is called.
    By Coder87C in forum C++ Programming
    Replies: 17
    Last Post: 01-31-2005, 06:04 PM
  4. Class function that returns the instance it's called from
    By L Boksha in forum C++ Programming
    Replies: 4
    Last Post: 05-25-2002, 11:52 AM
  5. Create class at run time
    By muaed in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 04-11-2002, 08:13 AM