Hello!
Many people talk about "a lot of overhead" without specifying what is "a lot".
I have used C++ on rather "small" microcontrollers (MSP430), and it works just fine.
Let's put numbers on what I call "small", I mean: 8k RAM and 32 k flash (for example
MSP430F5510).
I have still to see a real example written in both C and C++ version, with the same compiler.
I made experiments in the past using MSP430, IAR compiler, but for speed, not for size.
I found out that there is no speed difference as long as you do the same thing.
If you call a function vs call an object's method, you have a difference of 1 clock
(when using MSP430 + IAR). The reason is that in C case, you call the function directly, and in
C++ case, you call a method, which is a function that belongs to an object. I would not be
surprised that in C, if you call a function that belongs to a structure like this : S->F(), then
you get the same speed as when you call an object's method.
Now about Arduino: I made a quick test recently because some people said that
digital_write is slow. So I tried on a arduino mega, with atmel 2560. And indeed, doing
digital_write vs direct port access is extremely slow, you can divide the speed by at least
10. But if you don't use Arduino's specific functions, then it's as fast as C.
Well, sorry for the digression, I would like to see a simple program, for instance a thermometer,
in 2 versions, one in C and one in C++. Then compare the code size.
Now in case "size matters": this is more guts feeling, but my impression is that C++ allows
you to do some "source code factorization". What is done in the base class doesn't have
to be redefined. Very useful for graphics (even for small microcontrollers as above). And at
the end of the day, I wouldn't be surprised that you can save on code size, and beside this
I have never been short of flash or RAM by using C++.
Dora.