C++类信息的隐藏(三)

2012-11-30 12:26:19 · 作者: · 浏览: 834

 

    void handle::cleanup() {

    if(smile){

    delete smile;

    smile = NULL;

    }

    }

    int handle::read() {

    return smile->i;

    }

    void handle::change(int x){

    smile->i = x;

    }

    int main(){

    handle h;

    h.initialize();

    h.change(888L);

    std::cout《 (h.read());

    return 0;

    }

    [cpp]

    [cpp]

    这种风格可以用在隐藏类的信息。(主要功能)

    也可以减少编译时间。如果cheshire的组成改变了,之需要编译一个cpp.(按这种写法,cheshire是不易复用的)