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 468312
To view parent comment, click here.
To read all comments associated with this story, please click here.
vivainio
Member since:
2008-12-26

But most of the time I'd agree, C is overall the better easier to read language, if only humans never got RSI and man hours were infinite.


Take a look at how OO in C looks like:

https://maemo.gitorious.org/fremantle-hildon-desktop/libhildondeskto...

Reply Parent Score: 2

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

vivainio Member since:
2008-12-26

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

Reply Parent Score: 2

alexeiz Member since:
2011-03-30



Frankly, I can't see the forest for the trees in that code.

Reply Parent Score: 1

vivainio Member since:
2008-12-26


Frankly, I can't see the forest for the trees in that code.


That was my point.

Reply Parent Score: 2