Re: Best way to sort rooms...



Thanks for the suggestion, but unfortunately, I must write it
in C because 1) I don't have as much experience with C++ and
2) this program is being developed to run in both Linux and Windows.
Therefore, I'm somewhat restricted to using the C version.

"Timothy M. Shead" wrote:
> 
> This may be an unpopular sentiment for this list, but C++ makes this
> trivial, typesafe, and free of memory leaks.  Assuming you have a "Room"
> structure, you could define a "Building" as follows:
> 
>         #include <map>
>         #include <string>
>         using namespace std;
> 
>         typedef map<string, Room> Building;
>         Building shipman_hall;
> 
> inserting a room into the building is as simple as:
> 
>         shipman_hall["113a"] = Room();
> 
> ... and it will already be sorted.
> 
> Timothy M. Shead

-- 
+-----------------------------------------------------+
| Jeff "Shippy" Shipman     E-Mail: shippy@cs.nmt.edu |
| Computer Science Major    ICQ: 1786493              |
| New Mexico Institute of Mining and Technology       |
| Homepage: http://www.nmt.edu/~shippy                |
+-----------------------------------------------------+




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]