All the good time! There was a problem, I began to write a function to integrate 2 string and double arrays into one map.

map<string, double> toMap(const string* str,double* params){ map<string, double> rMap; //как узнать колличество элементов массиве str или params? return rMap; } toMap(new string[3]{"name1","name2","name4"}, new double[3]{1,2,3}); 

Methods such as sizeof and others do not help. Are there any other solutions?

    2 answers 2

    1. to know the size you need to store string and double in vector or array (by calling the size () method we get the size)
    2. do you have a memory leak, where is string[3] and double[3] deleted?

    and why to push 2 arrays in one map?

    • Thank you, everything worked out with the vector. I think I should better study the standard types in c ++ - RAZVOR
    • these are not types! these are data containers! or data structures! (in my opinion there is a big difference!) for starters, find out: 1. what is O notation (algorithm complexity) 2. what data structures (containers) are and how do they differ ps here is just a short list of data structures: array, vector, queue lists (unidirectional (LIFO, FIFO), bidirectional, closed), smart pointers, trees (binary, suffix, self-balancing (red-black, avl)), sets, maps, buffers ... - ProkletyiPirat

    And the vector can not be used here?

    Or use one more parameter to transfer their count.

    In general, your code is terrible ...

    • I am not good at c ++, I apologize for this, but how else can you pass arrays to a function so that you can work with them normally? And more than a vector better than the usual map? - RAZVOR 7:14 pm
    • Damn, is this hello ... Slippers are better than shoes? Well, you asked ... In general, @ProkletyiPirat wrote everything to you. - deterok
    • one
      It seems to me that you should start with the literature, and there it will go further and further, and that is a very superficial knowledge of standard containers. - deterok