设为首页 加入收藏

TOP

C++类信息的隐藏(一)
2012-11-30 12:26:19 来源: 作者: 【 】 浏览:821
Tags:类信息 隐藏

    C++(www.cppentry.com)编程(www.cppentry.com)思想里的一个例子。

    先看代码:

    handle.hpp

    [cpp]

    #ifndef HANDLE_H_

    #define HANDLE_H_

    class handle {

    struct cheshire;  //这里通知编译器cheshire是个结构体,结构体的定义编辑器将在cpp中找到

    cheshire* smile;

    public:

    void initialize();

    void cleanup();

    int read();

    void change(int);

    };

    #endif // HANDLE_H_

    handle.cpp

    [cpp]

    #include <iostream>

    #include "handle.hpp"

    using namespace std;

    struct handle::cheshire {

    int i;

    };

    void handle::initialize() {

    smile = new cheshire();

    smile->i = 11;

    }

   

首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇poj1523 解题报告 下一篇HDU 2962 Trucking

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: