Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7869327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:17:12+00:00 2026-06-03T01:17:12+00:00

Please assume a resource managing class, let’s say template<typename AddressFields> class AddressBook { std::list<AddressBookEntry<AddressFields>

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T01:17:14+00:00Added an answer on June 3, 2026 at 1:17 am

    There is most certainly. It’s called multiple inheritance:

    struct NameMobile : Name, Mobile {};
    

    This aggregates Name and Mobile into a new type NameMobile (including all their members, recursively). Since you’re declaring it with the struct keyword, the public modifiers (before Name and Mobile) are implied and can thus be omitted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say I have a code as a following: object[hash].init(); Please assume that hash
Please check the codes.. $(.editable).live(click,function(){ CurrentOBJhtml = $(this).text(); nextHtml = <input type='text' class='hoverable' value='+CurrentOBJhtml+'
Please assume the following contrived JavaScript: function do_something() { var x = 5; function
I am looking for a step-by-step Mercurial guide for iPhone projects . Please assume:
I have a quick question about Java synchronization. Please assume the following code: public
I have a quick question about Java synchronization. Please assume the following code: public
Let's assume I have two entities - project team and employee. Each employee could
Please assume that I do not need to worry about development time and costs:
I'm very new to OS X and XCode, so please don't assume I know
First off let me just say I'm very new to coding so there are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.