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 7555457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:36:49+00:00 2026-05-30T11:36:49+00:00

Is it possible to store multiple different class types in a single std::list object?

  • 0

Is it possible to store multiple different class types in a single std::list object?

I want to make multi-layered list that can store int and std::list as an element, and now am trying to use std::list for this purpose. I need to retrieve data from all the list from both top-level and subsequent layers too.

This question here is similar except that I want to use pre-defined class.

The following returns error at 4th line:

std::list<int> l;
std::list<int> subL;
l.push_back(1);
l.push_back(subL);

This returns error at 1st (and 3th according to the 1st line):

std::list l;
std::list<int> subL;
l.push_back(1);
l.push_back(subL);
  • 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-05-30T11:36:50+00:00Added an answer on May 30, 2026 at 11:36 am

    You could declare list <void*> and store to it pointers to any of your objects. But another question will raise how you’re going distinguish them to use? If you don’t need to, it’s OK.

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

Sidebar

Related Questions

I have a model where multiple classes have a list of value types: class
How can I store multiple different windows/dialogs in a single GtkBuilder file and then
Is it possible to a single database across multiple websites on different servers? What
Is it possible to store passwords on the local system (Windows XP) that can
Is it possible to store the credentials that I use to connect to my
Is it possible to implement batching of multiple stored procedure calls (doing updates/deletes) in
Is it possible to store encrypted connection string so it can be used from
Is it possible to store the results of a call to exec sp_executesql in
Is it possible to store a type name as a C++ variable? For example,
Is it possible to store erb templates in database? How?

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.