what is the better way to do the mapping?

K

kathy

I want to map number to letter, for example:

1 to AA
2 to ABC
3 to XYZ
and so on. The map size can be changed dynamically.

what is the better way to do that?
 
R

roberts.noah

kathy said:
I want to map number to letter, for example:

1 to AA
2 to ABC
3 to XYZ
and so on. The map size can be changed dynamically.

what is the better way to do that?

Two good options:

* vector<std::string>
* map<int, std::string>

Really depends on your needs. If you can have two indexes, one a low
value and one a rather high value, and nothing in between, then map is
probable best, otherwise I would use the vector.
 
A

Alf P. Steinbach

* kathy:
I want to map number to letter, for example:

1 to AA
2 to ABC
3 to XYZ
and so on. The map size can be changed dynamically.

what is the better way to do that?

To choose one way over another you need to consider your requirements.

Have you tried a std::vector?

If you have, and that wasn't good enough, why?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top