By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

Reverting to C in C++ Code

P: n/a
Hi, all,

I'm finding that in my new project I have developers that have been
developing in C++ for many years but they default to C code in most places.
As such, our code is C++ by compiler, but tends to be C by design and
appearance. As examples, they're used to using character prefixes for
library function and variable names instead of namespaces, favoring *printf
to streams and stringstreams, avoiding exceptions in favor of overloading
return values, and avoid the STL in favor arrays, character buffers, and
hand-rolled containers.

Most of the reasons for which I have chosen the C++ path in these decisions
lie in my own comfort level with the language. There are some clear
benefits of choosing C++ over C for some of these decisions (STL reliability
and robustness over char * comes to mind) but some of my choices seem to be
more about personal preference than correctness (using namespaces instead of
prefixes for library functions/variables).

I'd like to educate myself on the pros and cons of each of these and other
C/C++ decisions. I do have several books on C++ but none really attempt an
objective analysis of each of these features. Many rely on the notion of
"this is how you do it in C++". Unfortunately, that argument doesn't carry
weight with my coworkers.

Can anyone recommend a good source for this information? Books are better
than web pages, but at this point I'll take anything I can get.

Thanks!
Scott

--
Remove .nospam from my e-mail address to mail me.

http://www.e-scott.net
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Scott Brady Drummonds" <sc**********************@intel.com> wrote in
message news:ct**********@news01.intel.com...
Hi, all,

I'm finding that in my new project I have developers that have been
developing in C++ for many years but they default to C code in most places. As such, our code is C++ by compiler, but tends to be C by design and
appearance. As examples, they're used to using character prefixes for
library function and variable names instead of namespaces, favoring *printf to streams and stringstreams, avoiding exceptions in favor of overloading
return values, and avoid the STL in favor arrays, character buffers, and
hand-rolled containers.

Most of the reasons for which I have chosen the C++ path in these decisions lie in my own comfort level with the language. There are some clear
benefits of choosing C++ over C for some of these decisions (STL reliability and robustness over char * comes to mind) but some of my choices seem to be more about personal preference than correctness (using namespaces instead of prefixes for library functions/variables).

I'd like to educate myself on the pros and cons of each of these and other
C/C++ decisions. I do have several books on C++ but none really attempt an objective analysis of each of these features. Many rely on the notion of
"this is how you do it in C++". Unfortunately, that argument doesn't carry weight with my coworkers.

Can anyone recommend a good source for this information? Books are better
than web pages, but at this point I'll take anything I can get.


Have you read Stroustrup's "Design and Evolution of C++"?
Also you might find interesting Lippman's "Inside the C++ Object Model".

-Mike
Jul 23 '05 #2

P: n/a
I guess some of the issues you are mentioning are issues with
using C++. The more important thing is to make sure you have an
object oriented design.

When transition from C to C++, the difficult part is the transition
from procedural design to object oriented design.

The following articles might help:
http://www.eventhelix.com/RealtimeMa...esign_tips.htm
http://www.eventhelix.com/RealtimeMa...ign_tips_2.htm

Deepa
--
http://www.EventHelix.com/EventStudio
EventStudio 2.5 - Generate Sequence diagrams from a simple declarative
language

Jul 23 '05 #3

P: n/a
EventHelix.com wrote:
I guess some of the issues you are mentioning are issues with
using C++. The more important thing is to make sure you have an
object oriented design.

When transition from C to C++, the difficult part is the transition
from procedural design to object oriented design.
Who says that C programmers (programs) aren't object oriented?
Who says that a C++ programmer (program) must be object oriented?

Object Oriented Programming in C is just as good an idea as
Object Oriented Programming in C++.
The following articles might help:
http://www.eventhelix.com/RealtimeMa...esign_tips.htm
http://www.eventhelix.com/RealtimeMa...ign_tips_2.htm

Jul 23 '05 #4

P: n/a

E. Robert Tisdale wrote:
Who says that C programmers (programs) aren't object oriented?
Who says that a C++ programmer (program) must be object oriented?

Object Oriented Programming in C is just as good an idea as
Object Oriented Programming in C++.


Having written OO programs in both C and C++, let me tell you
that writing them in C leads to poorly readable C code.

E.g. your average C coder will not recognize

*(obj->vtable[obj_foo])(1)
or
SendMessage(obj, obj_foo, (void*)1 );
or
OOCALL( obj, foo, 1 ); /* nasty macro alert */

whereas your average C++ coder will understand
obj->foo(1);

Regards,
Michiel Salters

Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.