Welcome Guest [Log In] [Register]
Welcome to UCR CS 14 Klefstad.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Comparing with Templates
Topic Started: Nov 13 2013, 12:54 AM (63 Views)
Deleted User
Deleted User

Is there a single overarching algorithm to sort strings, ints, and whatever KeyType we want? If we're turning this BS tree into a template, then wouldn't trying to compare case-insensitive strings be different than just comparing ints or chars? Or do I not have to worry about that for this assignment?
Quote Post Goto Top
 
Deleted User
Deleted User

The templated function will simply call the correct operator based on the KeyType it receives. If the keytype doesn't have overloaded boolean operators then it will cast the key to a boolean when using the operators. This can lead to logic errors, but strings and ints have boolean operators, so it won't be a problem with this assignment.

EDIT: Derp. If something doesn't have boolean operators then trying to compare them is a compile-time error. I think the compiler checks to see if that happens with the templates at compile time.
Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Homework 6 · Next Topic »
Add Reply