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

  • Home
  • SEARCH
  • 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 7419185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:01:03+00:00 2026-05-29T08:01:03+00:00

Looking for an equivalent container class that matches to C#’s Arraylist collections class. Is

  • 0

Looking for an equivalent container class that matches to C#’s Arraylist collections class. Is there anything that comes close to a container that can provide index based enumeration as well as hold multiple data types.

What I am trying to do is implement a Model-View-Controler. I am trying to create a Controller that can internally manage different types of shape data-types (e.g.: Box2D, Circle2D, Circle3D, etc)

//Controller code
class Controller
{
    //internally track all shapes...

    void CreateShape(const Box2d &box); 
    void CreateShape(const Box3d &box);
    void CreateShape(const Circle2d &circle);

    //More Add/Edit/Remove Shape methods...

    void Reset(); //clear the container of shapes...
};

I am trying to create an vector or a different type of container that can hold multiple data types. For example:

//Is this line of code possible??
vector <int, string> vec;    

int i=0;
string str = "test";

//add different data-type objs into my vector mutable array
vec.push_back(i);
vec.push_back(str);

Please advise, if there are other container classes in C++ that might help me achieve this functionality or there is a way to use vector class to store multiple data-types.

  • 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-29T08:01:04+00:00Added an answer on May 29, 2026 at 8:01 am

    You may want something like this:

    class Shape {
    public:
        virtual void rotate(double degrees) = 0;
        virtual void scale(double newScale) = 0;
        virtual ~Shape(){}
        //etc, etc, etc...
    };
    
    class Box2d : public Shape {
    public:
        virtual void rotate(double degrees) {
            //Code for rotating...
        }
    
        //Implement other virtual methods...
    };
    class Circle2d : public Shape {}; //Implement virtual methods
    class Box3d : public Shape {}; //Implement virtual methods
    
    
    int main() {
        vector<Shape*> items;
        items.push_back(new Box2d());
        items.push_back(new Circle2d());
    
        //Now doing this:
        items[i]->rotate(180.0);
        //Will call Box2d's rotate function
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for the equivalent in Qt to GetTickCount() Something that will allow me
I'm looking for the equivalent of the Unix 'tail' command that will allow me
What I am looking for is the equivalent of System.Windows.SystemParameters.WorkArea for the monitor that
Is there an equivalent in WPF to the Titled Borders that exists in Java's
I'm looking for a container that keeps all its items in order. I looked
I'm looking for the equivalent to CTRL-Q of IntelliJ, that shows you the documentation
There is a shortcut in IntelliJ I'm looking equivalent in Eclipse, it is called
I'm looking for the equivalent of right clicking on the drive in windows and
I'm looking to the equivalent of Windows _wfopen() under Mac OS X. Any idea?
I'm looking for the equivalent of a urlencode for terminal output -- I need

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.