[Solved] std::map operation by value or pointer? [closed]


Will that cause memory leak ?

There are no memory leak in your program, but a compilation error, since there are no operator[] defined for struct B.

Assuming you add to map here:

while(true)
{
    A a;
    a[0] = 0;
    b[inx] = a;
    ++inx;
}

there are no memory leaks. The memory will increase until you use all int numbers, but that’s normal, since they have to be stored somewhere in memory.

0

solved std::map operation by value or pointer? [closed]