Like Tree2Likes
  • 2 Post By manasij7479

Create a class called date and a child class called time

This is a discussion on Create a class called date and a child class called time within the C++ Programming forums, part of the General Programming Boards category; Hello everyone, I am trying to learn c++ and I am having a very hard time understanding this problem. I ...

  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
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    > 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
    stahta01 and CoffeCat like this.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21