graph algorithm

hello everybody please tell me what is the error of this program?i cant understand anything about the error.

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
#include<list>
#include<iostream>
using namespace std;
class edge;
class vertex{
  public:
    char name;
    int id;
    list<edge> *v_edges;
    vertex(char _name=0,int _id=0):name(_name),id(_id){};
    void set_edges(list<edge>*_edges){
      v_edges=_edges;
    }
    friend ostream &operator <<(ostream &os ,vertex &v){return os<<"vertex name="<<v.name<<"vertex id="<<v.id;}
    friend istream &operator >>(istream &is ,vertex &v){return is>>v.name>>v.id;}
}; 
class edge{
  public:
    double weight;
    bool dir;
    vertex *source;
    vertex *dest;
    edge(bool _dir,double _weight=0):dir(_dir),weight(_weight){}
    friend ostream &operator <<(ostream &os ,edge &d){return os<<"source="<<*d.source<<"destination="<<*d.dest<<" direction"<<d.dir<<" weight"<<d.weight;}
    friend istream &operator >>(istream &is ,edge &d){return is>>*(d.source)>>*(d.dest)>>d.dir>>" weight">>d.weight;}
};
class graph{
};
int main(){
  
}

You have a const char* " weight" in line 25. Probably from when you copied it from line 24.

I think you probably intended it to be this:

 
friend istream &operator >>(istream &is, edge &d){return is >> *(d.source) >> *(d.dest) >> d.dir >> d.weight;
thanks very much ,that is you suggested.
Topic archived. No new replies allowed.