adspace
Is there any error below, its a code to delete all entires
from a map
#include <map>
#include iostream.h
int main()
{
int i =0;
map <int, char> TestMap;
while(i<3)
{
TesMap.insert(TestMap::value_type(i,Test));
i++;
}
typedef map<int, char> :: iterator mapIter =TestMap.begin();
if(mapIter!=TestMap.end())
{
TestMap.erase(mapItrer);
++mapIter;
}
return 0;
}
Answer Posted / Mohd Ullfat Ullha Khan
There are several issues with the provided code. Firstly, the 'map' library requires angle brackets (< >) instead of square brackets ([ ]) for templates. Secondly, 'iostream.h' is an input/output stream library and is not needed for map manipulation. Lastly, the 'int main()' function should be indented correctly to ensure the correct flow of the code.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers