| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: C++ for beginners? |
From: Tony Williams
Geo wrote:
> "John Beckett"
wrote in message
> news:419f1666.28883121{at}216.144.1.254...
>
>
>> // In practice, call the library qsort function.
>
>
> See now this is the part that really ticks me off, we were never shown a
> library function called qsort or even a way to find out if one exists. Seems
> to me library functions are one of the most useful features of C++ compared
> to other languages but they have shown us nothing about how to take
> advantage of what's available. I can understand not showing us MFC but they
> could have at least allowed us to use functions or classes we find on the
> net.
Maybe you're ready to take another look at the STL now. The C
"way" is to use library functions, and you're right that there
are many of them, but you can't guarantee that they are all available on
all platforms unless they're POSIX standard.
The C++ "way" is to find a good template library, subclass your
objects and use the methods provided by the library. For example, the STL
provides a sort algorithm that's at least as good as qsort and which is
just as easy to use.
BTW, just so you know where I'm coming from, I prefer to grub around with
low level code which hits the hardware directly and, IMO, C with embedded
assembler is the only sane way to do this. However, these days I spend most
of my time with large higher level programs and that's where C++ really
shines. Apart from exceptions, but that's another story.
I suppose that using bubble sort is ok if you're being asked to implement a
sorting algorithm, but if you're being asked to sort some items then learn
how to use existing methods/library functions. It's a valuable lesson
because using library functions is much faster/easier and less error-prone
than rolling your own. Once that clicks you'll see a whole world of code
out there just waiting for you to use it.
I know this is an NT group, but I suggest grabbing a Linux distro and
reading a few man pages. For this example a quick "apropos sort"
would have pointed you in the right direction.
I'm finding it very interesting reading about your progress. Thanks for
posting it and I hope you don't mind the back-seat driving.
--
Tony
> And you are correct about it being confusing learning classes for the first
> time. We are learning it as
>
> class blah // declaration
> {};
> blah::blah() // implementation
> {classvar=passedvar}
> void blah::funct() // class functions
> {return;}
>
> but what Gregg posted had all this in the public section which looked a
> whole lot more understandable to me. Course I'm not allowed to do it that
> way... So I'm questioning why they don't teach us the more elegant method?
>
> Lastly what's wrong with a bubblesort for a beginner class (yeah I know you
> high level programmer you )? Even beginners can understand how it works
> as it does what's needed in the simplest way. Yes I know the difference in
> efficiency between bubble and quick, but who's to decide what's more
> efficient when we are talking about not only how fast it operates but how
> fast you can code it?
>
> http://math.hws.edu/TMCM/java/labs/xSortLabLab.html
>
> I really like their demo, I used it to show my son how the different sorts
> work. But it seems to me they missed one, I recall a selection sort where it
> was selecting both min and max values during the same pass so it finished in
> half the time of the one shown there?
>
> Geo.
>
>
>
--- BBBS/NT v4.01 Flag-5
* Origin: Barktopia BBS Site http://HarborWebs.com:8081 (1:379/45)SEEN-BY: 633/267 270 5030/786 @PATH: 379/45 1 396/45 106/2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.