Re: Dynamically initiallizing an array
From: Paul (paulmmm01_at_hotmail.com)
Date: 04/25/04
- Next message: Roedy Green: "Re: Binary Trees"
- Previous message: marbac: "Re: Dynamically initiallizing an array"
- In reply to: Francis Glassborow: "Re: Dynamically initiallizing an array"
- Next in thread: Dan Moos: "Re: Dynamically initiallizing an array"
- Reply: Dan Moos: "Re: Dynamically initiallizing an array"
- Reply: Francis Glassborow: "Re: Dynamically initiallizing an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Apr 2004 13:59:27 -0700
Francis Glassborow <francis@robinton.demon.co.uk> wrote in message news:<5AzRu7Brr2iAFwsZ@robinton.demon.co.uk>...
> In message <33Fic.4983$2A3.354@news04.bloor.is.net.cable.rogers.com>,
> Cerf <dark_temp@hotmail.com> writes
> >> I don't know what exact problem you are having
> >
> >Opps I sent the wrong code
> >
> >#include <ostream>
> >using namespace std
> >
> >int main()
> >{
> > int x[] = {0, 1}
> > //code omitted
> >
> > //I want to add another element to the array but it wont let me, the
> >program crashes when I do so
> > int x[2] = 2
> >
> > cout << x[0] << endl << x[1] << endl << x[2] << endl;
> >}
> >
> You cannot do that. Arrays are fixed in size at the point of definition
> (or sometimes earlier).
>
> As you are using C++ the solution is to use a std::vector. If your text
> book is teaching you arrays before it teaches vectors consider another
> book.
>
I disagree.
I don't think you should be using vectors if you don't yet understand
how to use arrays.
> At the ACCU Spring Conference I was talking to an ex-University Lecturer
> in computer science (he left because he got tired of fight a system that
> tolerated blatantly bad lecturers). He expressed the opinion that all
> books on C++ published before 1997 should be withdrawn (he did allow the
> 'The Design and Evolution of C++' would be an exception). While he was
> putting the point more strongly than I would, I generally agree that
> books on C++ published before the C++ Standard was done are largely only
> of historical interest. The problem is that many new editions of older
> books retain the same organisation and structure. Effectively they are
> still the old books and inherit the flaws.
I am glad this ex-lecturer did leave because I object to him trying to
change the methods for learning C++.
It amazes me that many competent C++ programmers think they also have
the ability to understand how peoples minds work whilst learning.
If I were learning C++ and vectors were introduced by a teacher this
would be how it goes:
Student to teacher: What do the angle brackets do?
Teacher: This is the syntax for template arguments.
Student: What's a template?
Teacher: You haven't learned about templates yet.
Student: Can I learn what a template is now then?
Teacher: No you are not ready to learn about templates yet.
Student: Why are you teaching me to use the STL then?
Teacher: ???Because it makes my life easier???.
When you can give me a good answer for this student then I would
*consider* this method of teaching as feasible. Until then why try to
change a perfectly good and proven method?
I have seen it said that this speeds up learning and this is why it is
preferred, but I think the longer you spend learning the better and I
don't see this as a good reason.
But putting our disagreements aside I would like to ask you why you
think this idea of introducing the STL early in a learning curve is
advantagous.
Best Regards
Paul.
- Next message: Roedy Green: "Re: Binary Trees"
- Previous message: marbac: "Re: Dynamically initiallizing an array"
- In reply to: Francis Glassborow: "Re: Dynamically initiallizing an array"
- Next in thread: Dan Moos: "Re: Dynamically initiallizing an array"
- Reply: Dan Moos: "Re: Dynamically initiallizing an array"
- Reply: Francis Glassborow: "Re: Dynamically initiallizing an array"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|