sign in | join about | help | sitemap
Connecting Tech Pros Worldwide
KK's Avatar

defining keys


Question posted by: KK (Guest) on July 11th, 2006 09:05 AM
How to define keys in c++??
can anyone help on this?

6 Answers Posted
Marco Wahl's Avatar
Guest - n/a Posts
#2: Re: defining keys

"KK" <Kartikeya.Karnatak@gmail.comwrites:
Quote:
Originally Posted by
How to define keys in c++??


You can e.g. do the following.

int main()
{
int keys = 42;

return 0;
}
Quote:
Originally Posted by
can anyone help on this?


Could you give more details on your need?


--
Marco Wahl

Robbie Hatley's Avatar
Robbie Hatley July 11th, 2006 09:45 AM
Guest - n/a Posts
#3: Re: defining keys

"KK" <Kartikeya.Karnatak@gmail.comwrote:
Quote:
Originally Posted by
How to define keys in c++??



int keys;


Oh, you say that's not what you meant? I guessed it
might not be. But since there is something like a googol
(google "googol") of different ways to interpret your
question, I just chose one at random.

If you would care to elaborate, perhaps I could be of
more help.

--
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/


Frederick Gotham's Avatar
Frederick Gotham July 11th, 2006 12:55 PM
Guest - n/a Posts
#4: Re: defining keys

KK posted:
Quote:
Originally Posted by
How to define keys in c++??
can anyone help on this?



My guess wudda been:

#define keys


--

Frederick Gotham
Julián Albo's Avatar
Guest - n/a Posts
#5: Re: defining keys

KK wrote:
Quote:
Originally Posted by
How to define keys in c++??


class keys { };

--
Salu2
Howard's Avatar
Guest - n/a Posts
#6: Re: defining keys


"KK" <Kartikeya.Karnatak@gmail.comwrote in message
news:1152605420.096287.185110@b28g2000cwb.googlegr oups.com...
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).

-Howard


Robbie Hatley's Avatar
Robbie Hatley July 12th, 2006 12:45 AM
Guest - n/a Posts
#7: Re: defining keys

"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/


 
Not the answer you were looking for? Post your question . . .
197,028 members ready to help you find a solution.
Join Bytes.com

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 197,028 network members.
Post your question now . . .
It's fast and it's free

Popular Articles

Top Community Contributors