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;
}