《有效的c++》之条款31:将文件间的编译依存关系降至最低

  

# include  & lt; string>   # include “date.h”   # include “address.h”   class 人   {   公众:   ,,,的人(const  std:: string&,名字,const  Date&,生日,   ,,,,,,,,,,const  Address&, addr);   ,,,std:: string 名字(),常量;   ,,,std:: string 生日(),常量;   ,,,std:: string 地址(),常量;   ,,,…   私人:   ,,,std:: string  name;//实现细目   ,,,Date  theBirthDate;//实现细目   ,,,Address 地址;//实现细目   };

# include  & lt; string>   # include “date.h”   # include ”地址。h”

# include  & lt; string>   # include  & lt; memory>      class  PersonImpl;//人实现类的前置申明   class 日期;//人接口用到的类(日期、地址)的前置申明   class 解决;      class 人   {   公众:   ,,,的人(const  std:: string&,名字,const  Date&,生日,   ,,,,,,,,,,const  Address&, addr);   ,,,std:: string 名字(),常量;   ,,,std:: string 生日(),常量;   ,,,std:: string 地址(),常量;   ,,,…   私人:   ,,,std:: tr1: shared_ptr, pImpl;//智能指针要查看,指向实物   };

# include “Person.h”   # include “PersonImpl.h”      人::人(const  std:: string&,名字,const  Date&,生日,   ,,,,,,,,,,,,,,const  Address&, addr)   ,,,,,,,,,,,,,,,,pImpl (new  PersonImpl(姓名、生日、addr))   {,}      std:: string 人::名称(),const   {   ,,,return  pImpl→名称();   }

并不会改变它做的事,只会改变它做事的方法。

<人力资源/>


<李>

<李>

《有效的c++》之条款31:将文件间的编译依存关系降至最低