0

HI guys

I am using STL map in one of my project . I want to limit my size of my STL map size based on the use input , how do i do it .

For Example : if the user types in 5 as input then my program should be able to insert only 5 elements into my map not more that that . Hodo i do such allocation. Thanks

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by dkalita
0

u can do that by keeping a counter or as follows:

class mymap
{
     map<.....>  m;
     int maxsize=5;//say

/*if(m.size()<maxsize)       then only do more addition to it. Else dont.*/
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.