Index: [thread] [date] [subject] [author]
  From: Huned M. Botee <huned.botee@duke.edu>
  To  : 
  Date: Sat, 13 Feb 1999 21:30:28 +0000

Re: using sort....

Luke Palmer wrote:
> 
> part of my program uses a vector of slists of pointers to appointments to
> hold the schedule for an entire week (each slist represents a day, and can
> hold a variable number of appointments).  i want to use the sort member
> function built into slist to get all the appointments in order, but i am
> guessing that it will just sort the pointer values.  assuming i have written
> comparison operators for my appointment class, how can i get sort to look at
> what the pointers represent, rather than the pointer values themselves?
> using appointments instead of pointers to appointments would solve the
> problem, but waste a lot of memory because of all the copies that have to be
> made at different points in the program.  any ideas?  thanks.
> -luke

You could simply dereference the pointer and use the objects (from
pointer you just dereferenced) in the sort. The normal warnings for
pointers apply. Bus errors will result if you dereference something that
isn't there. (i think)

Dereference? It's as follows.

Say p is a pointer to an object, and that p is not null (ie, points to
something). Then, you can dereference it to get at the object:

Object thingPpointsTo = *p;

Pointers make ugly code, no?

-- 


Huned M. Botee
huned.botee@duke.edu


Index: [thread] [date] [subject] [author]