S
S
s2sk2018-01-29 23:03:13
C++ / C#
s2sk, 2018-01-29 23:03:13

Accessing array cells not by "number"?

Hello.
How can I access cells in an array not by "number", but by the type I want? Well, for example, I wanted char[]
int array[];
array["hello"] = 1;
Thank you all in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
L
longclaps, 2018-01-29
@longclaps

c++ map container

D
Denis Zagaevsky, 2018-01-29
@zagayevskiy

No. A raw array is essentially just a region of memory. Array indexes (numbers) are shifts in this memory relative to the beginning of the array.
Associative containers, such as hash tables, have similar behavior. One implementation in C++: en.cppreference.com/w/cpp/container/unordered_map

M
Maxim Moseychuk, 2018-01-29
@fshp

std::map

D
devalone, 2018-01-29
@devalone

No way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question