Prevent direct access to std::map keys

后端 未结 2 910
野的像风
野的像风 2021-01-07 05:01

I would like to wrap a std::map so the client is unaware that I am storing their positive integer keys actually as negative integers. I need to allow iterating

2条回答
  •  既然无缘
    2021-01-07 05:20

    do 
    {
        std::cout << "key: " << key << " val: " << value << std::endl;
    }while (o.getNextElement(key, value));
    

    So all operations are within the loop like this.

提交回复
热议问题