Your problem is with line 5 and your variable next. Because you have brought in the entire std namespace, your variable next is interpreted as std::next which is a very different thing.
So this is a very good reason not to have line 5, instead prefix every std thing with std::, as in: std::ifstream , std::cout. If you look at code posted here by experts like Cubbi and JLBorges and many others, they never bring in all of std and always use std::
Also, it is a good idea to declare an initialise each of your variables to something, preferably one per line.
line 20 can be written: num += next;
I hope this helps you out a bit, and you have a great day.