Adjacent list

I am trying to find out the adjacent list of my cities class.
I did this function but there are a bug somewhere in the code.
Can anybody suggest me what to do. I will use vector and list.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50

list<City*> City::getAdjacent(){
	// return a copy of the adjaceny list
	
	std::vector<std::list<City>> clist;
	// open file

	string fileContents;
    int y,z;
    string x;

    ifstream fin;
    fin.open("townlist.txt");
    while(fin>>x>>y>>z)
    {
      //  getline(fin,fileContents,'\x1A');
        
        istringstream iss(fileContents);

    // Read from the file contents

    iss >> x;
    iss >> y;
    iss >> z;

    clist.push_back(x);

    // Display the integers
    //cout << x << ' ' << y << ' ' << z << '\n';
    }
    
    fin.close();

	std::vector<std::list<City>> iterator i;
	int c = 0;
	for(i = clist.begin(); i != clist.end(); ++i)
	{
		cout<<c<<endl;


		std::list<City> li = *i;
		for(std::list<City>::iterator iter = li.begin(); iter != li.end(); ++iter)
		{
			cout<<*iter<<endl;

		}

		c++;
	}
}
There are several errors.

Line 26: The type to push_back is std::list<City> but you provide string.

Line 34: Change to std::vector<std::list<City>>::iterator i; // Note ::

Line 50: list<City*> must be returned.
Topic archived. No new replies allowed.