"Howard" <alicebt@hotmail.comwrote:
Quote:
Originally Posted by
"KK" <Kartikeya.Karnatak@gmail.comwrote:
Quote:
Originally Posted by
How to define keys in c++??
can anyone help on this?
>
In case the abundance of smart-ass answers hasn't clued you in... nobody
knows what you're talking about! :-)
>
If this is a database questions, then ask in a database newsgroup.
>
If you think it is actually a C++ _language_ question (the topic of this
newsgroup), then post back with some more details of what you're asking.
The word "keys" is just too general to know what you're referring to, and
isn't a term used in describing anything in the C++ language (at least not
that I'm aware of).
Well, maps and multimaps use keys. Which can basically be any simple
type for which "<" is defined, so that maps can be ordered by keys.
Which is why I made some smartass comment about "int".
If I remember right, the code for that looks something like this:
typedef unsigned long student_id; // "key" type
typedef std::string student_name; // "value" type
std::map<student_id, student_nameStudentBody;
void AddStudent(student_id id, student_name name)
{
::StudentBody.insert(std::make_pair(id, name));
}
void DeleteStudent(student_id id)
{
::StudentBody.erase(id);
}
std::string GetName(student_id id)
{
return ::StudentBody[id];
}
I don't know if map keys is what the person had in mind though.
--
Cheers,
Robbie Hatley
East Tustin, CA, USA
lone wolf intj at pac bell dot net
(put "[usenet]" in subject to bypass spam filter)
http://home.pacbell.net/earnur/