インターフェイスには抽象基本クラスを使用し、実装には派生クラスを使用しました。以下のコードを参照してください。C++ の標準的な設計パターンに関連付けることはできますか?
Class people
{
public:
virtual void setname(string name)=0;
virtual void SetAge(int Age)=0;
//etc consists of only pure virtual functions like above
};
Class Students: public people
{
void setname(string name)
{
//implementation of the function
}
void SetAge(int Age) { //implementation }
}
そして、私は上記のように多くのクラスを定義し、オブジェクトは Buildclass のコンストラクターで次のように作成されました。
Buildclass::Buildclass()
{
people *Obj = (people*) new Students();
interface *obj1 = (interface*) new implementation();
}
そして、上記のgetinstance関数を別のレイヤーで使用するために提供しました
void BuildClass::getPeopleinstance()
{
return Obj;
}
void BuildClass::getAnotherinstance()
{
return Obj1;
}
上記のコードは、任意の設計パターンに関連付けることができますか? 私にお知らせください?私は見つけることができません。