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.
Thread beginning with comment 468343
To view parent comment, click here.
To read all comments associated with this story, please click here.
Member since:

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 */

/* Calls simple_clock set_time() function */

/* Calls date_clock set_date() function */

/* Calls utc_date_clock set_utc_time() function */

/* Cast to (simple_clock_t *) object pointer */
/* 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 */
/* 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 */
/* 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);

/* 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)

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

vivainio Member since:

You don't have the class declarations in your example. Of course calling stuff is trivial.

Reply Parent Score: 2