さまざまなオブジェクトを格納できる一般的なストレージクラスを用意したいと思います。それらをすべて格納する異種コンテナクラスを使用したくありません。私は、テンプレートストレージ・クラスを作成すると考えると、これは、異なるタイプとメタクラスを継承する一般的なストレージ・クラスを作成します。以下のようにテンプレートクラスからの多重継承
template<typename Type>
struct SingleInterface
{
public:
SingleInterface() = default;
virtual ~SingleInterface() = default;
SingleInterface(const SingleInterface &) = default;
SingleInterface & operator=(const SingleInterface &) = default;
SingleInterface(SingleInterface &&) = default;
SingleInterface & operator=(SingleInterface &&) = default;
void get(const std::string & keyword, Type * ptr)
{
// implementation
}
};
私の一般的なクラス:
class MutliInterface: public SingleInterface<double>, SingleInterface<int>
{
public:
MutliInterface() = default;
virtual ~MutliInterface() = default;
};
私はMutliInterfaceクラスを作成します
MutliInterface interface;
double *v;
interface.get("test", v);
'get' is ambiguous '
getメソッドに入力してください。あいまいさを解決しますか? void get(const std :: string&keyword、Type * ptr) – apramc