[OT] Quick intro to C++ for a Python and C user?
Roy Smith
roy at panix.com
Wed Dec 21 09:26:04 EST 2011
In article <9le7c5F1lsU1 at mid.individual.net>,
Neil Cerutti <neilc at norwich.edu> wrote:
> On 2011-12-20, Paul Rubin <no.email at nospam.invalid> wrote:
> > Grant Edwards <invalid at invalid.invalid> writes:
> >> Oops. I should have mentioned this is for embedded systems
> >> programming so templates in general (and STL in particular)
> >> are probably off the table.
> >
> > Templates are how C++ does generics and I'd expect them to
> > appear in be used in embedded programming as well as elsewhere.
> > They can bloat up the code if you're not careful (if function f
> > has several parameters, you can end up with a separate,
> > specialized copy of f for every combination of types that f is
> > called with in the program), but in the typical monomorphic
> > situation they don't add any overhead. I'm not sure about the
> > situation with STL. Anyway, templates aren't terribly hard to
> > understand.
>
> Moreover, if you don't plan to take advantage of templates or
> inheritance, then you could as well write C++ compatible C and be
> pretty happy with the results.
Well, C++ still gives you constructors, destructors, and the ability to
write class-specific operators.
But, you'd be missing one of C++'s biggest selling points; safe
containers. Even if you never explore anything in STL beyond std:string
and std:vector, you will have saved yourself a world of buffer overflow
pain.
More information about the Python-list
mailing list