构造函数、重载例子

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

 

posted @ 2017-02-19 16:28  变通无敌  阅读(356)  评论(0编辑  收藏  举报