Linked by anonymous on Tue 29th Mar 2011 16:05 UTC
General Development The C++ programming language is about to be updated, as the ISO steering committee for the language has approved the final draft specifying its next version. The ISO/IEC Information Technology Task Force will review the steering committee's Final Draft International Standard will review and, barring any complications, publish the draft later this year. It will be known as C++ 2011.
Permalink for comment 468343
To read all comments associated with this story, please click here.
rom508
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

Reply Parent Score: 1