2014-02-11 39 views

回答

0

當然,由我應該嘗試的方式..

例如:

/* Your user-define object */ 
class A { 
public: 
    A(const int& x = 4) : x_(x) {} 
    operator int() {return x_;} 
private: 
    int x_; 
} 

class B { 
public: 
    B(const int& y = A(3)) : y_(y) {} 
    /* OR */ 
    B(A* a = new A(4)) : a_(a) {} 
private: 
    int y_; 
    A* a_; 
} 
相關問題