Initial value in map

Initially what is the value in map<T , bool> visited;

Hello @bvidab18,

As soon as you access the map with the [] operator, if the key doesn’t exist it gets added. The default initializer of the int type gets invoked - so it will get a value of 0.

So, basically:
the default value will be the default of that type. If you want another default, you can create a class that behaves like an int but has a different default constructor.

Hope, this will help.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.