??????????????????? ??????????#include
????????????? 5???????? ????ζ????5????????????????????????????????? ?????? ?????????5 ??????????2???????????
????1.??????????#include??????? ?????????? (forward declared )
????1.1??????? iostream?? ???????c++ ??????c++ primer?? ??????????????????????? iostream ????????? ????????? ???????????????????? ??????????????????? ??????ostream ????
????1.2.ostream?????????? ?滻? iosfwd ?? ????? ?????? ?????????????????????????????????? ??iosfwd ????? 678?У?????????vs2013????????????????λ??????????????????????????? ????????
????typedef basic_ostream<char?? char_traits<char> > ostream;
????inline std::ostream& operator<<( std::ostream& os??const old& old_val )
????{ return old_val.print(os); }
?????????????????????????????ostream ???? ????????#include <ostream> ?? ??????????? ????? ????????????ostream ???? ?????????????????
??????????ж?????????? std::ostream os?? ?????????????????????????????????????? ????#include ??????????? ????????????????????????????????????? class XXX; ?????????????????????????????
???????????? old.h??????????????????
//  old.h: ????????????
//
#include <iosfwd>  //???滻??????
#include <list>
// 5 ?? ?????file ?? db?? cx?? deduce or error ?? ??????????????
// ??? file and cx ???麯??.
#include "file.h"  // class file  ?? ??????????????????????????????????old ????????????????
#include "db.h"  // class db?? ?????????????????
#include "cx.h"  // class cx
#include "deduce.h"  // class deduce
// error ?????????????????????? ??????????滻#include  "error.h"
class error??
class old : public file?? private db {
public:
old( const cx& );
db  get_db( int?? char* );
cx  get_cx( int?? cx );
cx& fun1( db );
error  fun2( error );
virtual std::ostream& print( std::ostream& ) const;
private:
std::list<cx> cx_list_; //  cx ????????????????????????????????????????????????cx.h ???????????
deduce       deduce_d_; //  deduce ????????壬??????????????
};
inline std::ostream& operator<<( std::ostream& os??const old& old_val )
{ return old_val.print(os); }
???????????? ??????Щ???? ???????????????????????????????ж??? ???????д?????????????????д????????
??????????C++ ????и????????????? ????????????????????????????????? ????????????辶??
????2. ????????????????г?????????????? "impl" ????
????2.1.??? "impl" ?????д???????????????????????
????impl ???????????? ?????г???????????????impl ?? ????????????г??????????????impl* ???????????
????// file old.h
????class old {
????//???к???????
????// public and protected members
????private:
????//??г???? ????????????????????仯??????????????????????????old.h????????????±???
????// private members; whenever these change??
????// all client code must be recompiled
????};
??????д????????
// file old.h
class old {
//???к???????
// public and protected members
private:
class oldImpl* pimpl_;
//  ?滻???????????г??????????impl?????????????????????????????????д??????????????????????????? ????????
//????????????д
// a pointer to a forward-declared class
};
// file old.cpp
struct oldImpl {
//?????????????????????? ????仯?? ?????????????????±???
// private members; fully hidden?? can be
// changed at will without recompiling clients
};