|
|
Warp wrote:
> Why would a beginner need to deal with constructors, destructors,
> exceptions and the like?
Because they'll be using libraries that require such. Even in your example,
you'd have to talk about the std::string constructor and how it creates an
empty string if you don't pass it arguments. As opposed to (say) integers,
that don't get initialized to zero. And what happens if you run out of
memory in your concatenate function.
> No, C is a lot more complicated for the beginner precisely because it's
> less powerful.
I disagree. It's more complicated to get things done, but easier to understand.
> std::string concatenate(const std::vector<std::string>& strings)
> {
> std::string result:
> for(int i = 0; i < strings.size(); ++i)
> result += strings[i];
> return result;
> }
> Show me the same function implemented in C and explain how it would be
> easier for a beginner (especially without any danger of memory leaks).
It would be easier to explain what's happening. I don't have to explain the
syntax for method invocation, const, references, the difference between
references and pointers, the differences between method invocations on
references and pointers, overloaded operators, or what namespaces are. The
function will be longer and more dangerous, but the only "unusual" things to
be explained are pointers and strings. Basically, in the C equivalent, the
only *confusing* part is that C doesn't allocate multi-word objects for you.
I take it you've never actually taught beginner computer programming
classes, yes?
It's not "how much power do you have." It's "how much do you have to
dismiss as magic before you have a full understanding of the entire language."
--
Darren New, San Diego CA, USA (PST)
The question in today's corporate environment is not
so much "what color is your parachute?" as it is
"what color is your nose?"
Post a reply to this message
|
|