mercredi 26 août 2015

Using constructor declaration as a virtual function

I am not sure whether the question title is appropriate with respect to the details below.

I am working with a number of datasets which are widely different. So, I conceptualised that I would create a Base class "Dataset", from which "Dataset1", "Dataset2" etc would inherit. Now the situation is as follows:-

I want to have a uniform constructor as follows :-

Dataset(std::string category, )

So, for each dataset class I want to initialize them with category as the first argument and other variable arguments (which depend upon specific dataset).

My question is :-

Can I have a virtual constructor function in Dataset class, which can be inherited by "Dataset1", "Dataset2" and so on ? Is this the right design choice ? How do I implement it (variable arguments etc ) ?

Aucun commentaire:

Enregistrer un commentaire