Please assume a resource managing class, let's say
template<typename AddressFields>
class AddressBook
{
std::list<AddressBookEntry<AddressFields> > book;
};
which holds a list of AddressBookEntry objects. AddressBookEntry basically is supposed to consists of a couple of default member variables plus a customizable fields variable described by the templated AddressFields:
template<typename AddressFields>
struct AddressBookEntry
{
int id;
AddressFields fields;
};
I'd like to provide a few basic structures such as
struct Name
{
std::string n_first;
std::string n_last;
};
struct Address
{
std::string street;
int zip;
std::string city;
};
struct Mobile
{
std::string m_number
};
Now my question is: Is there a way to create new structures based on the existing structures ? I want to allow a user to create his/her own custom AddressFields type by combining, for example, "Name" and "Mobile" to
struct NameMobile
{
std::string n_first;
std::string n_last;
std::string m_number;
};
so it can be plugged into AddressBook. But only with already existing structures.