cin.ignore(numeric_limits::max(), '\n'); max() not recognize it

前端 未结 5 1950
北恋
北恋 2020-12-13 20:44

I\'m taking an intro to C++, and I\'m using VStudio 2013 on Win7. I try to avoid the wrong data input from my menus, and it\'s working in all of them except this one.

<
5条回答
  •  佛祖请我去吃肉
    2020-12-13 21:21

    This is because in Visual Studio when you use the windows includes it will define a macro max(). If you hover over the max() in your example you should receive an intellisense warning. You can solve this problem by undefining max after all your includes and before any code.

    #undef max
    

提交回复
热议问题