构造函数、重载例子

struct ListNode{  
    int val, add;  
    ListNode*next;  
    ListNode() :val(0), add(0), next(NULL){};  //构造函数
    ListNode(int x) :val(x), add(0), next(NULL){};  //函数重载
};  
View Code
typedef struct Node  
{  
    int curAdress, key, nextAdress;  
    bool exist;  
    Node(){exist = false;}   //构造函数
    bool operator < (const Node& orh) const  //排序时会默认按照该方式(小于即升序)
    {  
        return key < orh.key;  
    }  
}Node; 
View Code
原文地址:https://www.cnblogs.com/wuxiaotianC/p/6416132.html