背景
在学习c++设计模式的Pimpl时,一共编写了三个文件:try.h、try.cpp和test.cpp,其中主函数包含在test.cpp中,并在该文件中调用try.h头文件中自定义的类;try.h中的具体实现细节被封装在try.cpp中。
//try.h
class Line
{
public:
Line(int x1, int y1, int x2, int y2);
~Line();
void printLine() const;
private:
class LineImpl;
LineImpl *_pimpl;
};
//try.cpp
#include
#include"try.h"
using namespace std;
class Line::LineImpl
{
public:
LineImpl(int x1, int y1, int x2, int y2);
void printLineImpl() const;
private:
class Point
{
public:
Point(int x=-1, int y=2)
:_x(x)
,_y(y)
{
cout |