重载运算符
重载小于号错误的写法
sturct node{
     int id,dis;
     bool operator<(node x)const{
          return x.dis<dis;                    
     }
}
正确的写法
sturct node{
     int id,dis;
     bool operator<(node x)const{
          return dis<x.dis;                    
     }
}
易于区分的写法 :friend 友元
struct node{
     int id,dis;
     friend bool operator<(node x,node y){
         return x.dis<y.dis;
     }
};
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号