Reading and using lines from a txt file

Hi, i have to read lines from a file and using this lines to create objects.
Example: I have this txt file that represents a group of undirected graphs.

5
A B 4
A C 10
A D 3
B E 6
C A 9
4
A B 3
A D 2
B C 4
C D 3
0

Number 5 is the number of edges for the first graph and the following lines are graph's edges.
Number 4 is the number of edges for the second graph and the following lines are graph's edges.
Number 0 stops software.

I have many difficulties reading this file to create edges. I have thought that I can read file with the help of single integers but I don't have find any solution. For edges probably i can use overloaded cin operator.

Sorry for my english, if i made errors.
Topic archived. No new replies allowed.