Linked by anonymous on Tue 29th Mar 2011 16:05 UTC
Permalink for comment 468343
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.
Features
Linked by Thom Holwerda on 05/21/13 21:38 UTC
Linked by Thom Holwerda on 05/20/13 11:29 UTC
Linked by Thom Holwerda on 05/18/13 21:33 UTC
Linked by David Adams on 05/16/13 4:23 UTC
Linked by Thom Holwerda on 05/11/13 21:41 UTC
Linked by Thom Holwerda on 05/08/13 14:22 UTC
Linked by Thom Holwerda on 05/02/13 15:28 UTC
Linked by Thom Holwerda on 04/29/13 21:06 UTC
Linked by Thom Holwerda on 04/24/13 22:24 UTC
Linked by Thom Holwerda on 04/18/13 11:21 UTC
More Features »
Sponsored Links



Member since:
2007-04-20
Or something like this:
#include "utc_date_clock.h"
#include <stdio.h>
/*
Object inheritance hierarchy:
simple_clock (Current time)
|
+-date_clock (Current time + date)
|
+-utc_date_clock (Current date + UTC time)
*/
int main(void)
{
/* Clock object */
utc_date_clock_t uc;
/* Constructor */
utc_date_clock_init(&uc);
/* Calls simple_clock set_time() function */
utc_date_clock_set_time(&uc);
/* Calls date_clock set_date() function */
utc_date_clock_set_date(&uc);
/* Calls utc_date_clock set_utc_time() function */
utc_date_clock_set_utc_time(&uc);
/* Cast to (simple_clock_t *) object pointer */
printf("\n");
/* Calls virtual display() function */
simple_clock_display_rtb((simple_clock_t *)&uc);
/* Calls non-virtual display() function */
simple_clock_display((simple_clock_t *)&uc);
/* Cast to (date_clock_t *) object pointer */
printf("\n");
/* Calls virtual display() function */
date_clock_display_rtb((date_clock_t *)&uc);
/* Calls non-virtual display() function */
date_clock_display((date_clock_t *)&uc);
/* Cast to (utc_date_clock_t *) object pointer */
printf("\n");
/* Calls virtual display() function */
utc_date_clock_display_rtb((utc_date_clock_t *)&uc);
/* Calls non-virtual display() function */
utc_date_clock_display((utc_date_clock_t *)&uc);
printf("\n");
/* Virtual destructor */
simple_clock_free_rtb((simple_clock_t *)&uc);
return 0;
}
atom$ gcc -O -Wall simple_clock.c date_clock.c utc_date_clock.c clocks_main.c
atom$ ./a.out
simple_clock_init() returning
date_clock_init() returning
utc_date_clock_init() returning
30/03/2011 (UTC 12:37:51)
12:37:51
30/03/2011 (UTC 12:37:51)
12:37:51 30/03/2011
30/03/2011 (UTC 12:37:51)
30/03/2011 (UTC 12:37:51)
simple_clock_free() returning
date_clock_free() returning
utc_date_clock_free() returning