C++ CIN cin skips randomly

点点圈 提交于 2019-12-02 02:16:07

I would guess that some of your inputs have spaces in them, which the >> operator treats as the end of a particular input item. The iostreams >> operator is really not designed for interactive input, particularly for strings - you should consider using getline() instead.

Also, you are needlessly using dynamic allocation:

assignment = new Assignment(assignment_name);

would much better be written as:

Assignment assignment(assignment_name);

you should avoid the use of 'new' in your code wherever possible, and instead let the compiler take care of object lifetimes for you.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!