????C++??????????????
???????????? ???????[ 2015/8/27 11:29:34 ] ??????????????????? .NET
????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
????};
???????????????????У? ?????????????д?????????£???????????????????????????????????????£?
???????impl?????????????
// ??? file and cx ???麯??.
#include "file.h"
#include "db.h"
class cx;
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:
class oldimpl* pimpl;
//???????????????
};
inline std::ostream& operator<<( std::ostream& os??const old& old_val )
{ return old_val.print(os); }
//implementation file old.cpp
class oldimpl{
std::list<cx> cx_list_;
deduce dudece_d_;
};
????3. ??????????????????
??????????????????????????????в??????? old class ???????????????? class old ???file ?? db ?? ???file????м?У????db ????м??
?????????file ??????? ???file ?????麯???? old ???????????? ??????????????裬 ???file ?? cx ???麯??????м??db ????????! ???????????????
??????? ??м??—???????????????????????????????Java??final??????????????????????????????????? ?????????м???????????? ?????e???????????db?????????? ????????
??????”db.h”????????? ??db ????????????impl???У??????????????????
// ??? file and cx ???麯??.
#include "file.h"
class cx;
class error;
class db;
class old : public file {
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:
class oldimpl* pimpl;
//???????????????
};
inline std::ostream& operator<<( std::ostream& os??const old& old_val )
{ return old_val.print(os); }
//implementation file old.cpp
class oldimpl{
std::list<cx> cx_list_;
deduce dudece_d_;
};
????С????£?
???????????????????????????????????????
????1. ??????????#include??????? ?????????? (forward declared )
????2. ????????????????г?????????????? “impl” ????
????3. ??????????????????
????????????????????????? ??????????????????????ο??????????????????????????????????????? ??????????????????????н?? ??????????????????impl???????????????£??????…
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11