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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:51:27+00:00 2026-05-23T09:51:27+00:00

I’m new to C++ so this is probably a very simple question, but I

  • 0

I’m new to C++ so this is probably a very simple question, but I haven’t been able to find any examples online that have helped.

I’ve defined my own Bubble class and I need to create a vector/list (I’m used to C# and Java, so I’m not sure which is correct) to dynamically store Bubble objects in. Here’s my code so far:

#include "Bubble.h"
#include <vector>
#include <list>

int backgroundImages[10]; 
list<Bubble> bubbles;
vector<Bubble> bubbles_two;
Bubble b;

void AppMain()
{
    loadImages();
    ViewAdd(backgroundImages[8], 0,0);
    b = Bubble();
    b.velocity = Vector2D(9,4);

    //I know this can't be right..
    bubbles.add(b);
    bubbles_two.add(b);
}

Neither the list nor the vector works – it says “list/vector is not a template” in my error list.

Which should I use, list or vector? And how do I correctly implement it?

  • 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-23T09:51:27+00:00Added an answer on May 23, 2026 at 9:51 am

    The functions vector.add() and list.add() do not exist.

    #include "Bubble.h"
    #include <vector>
    #include <list>
    
    int backgroundImages[10]; 
    std::list<Bubble> bubbles(); // use the std namespace and instantiate it
    std::vector<Bubble> bubbles_two(); // same here
    Bubble b;
    
    void AppMain()
    {
        loadImages();
        ViewAdd(backgroundImages[8], 0,0);
        b = Bubble();
        b.velocity = Vector2D(9,4);
    
        //I know this can't be right..
        bubbles.push_back(b); // std::list also defines the method push_front
        bubbles_two.push_back(b);
    }
    

    There are almost no obvious differences between the vector and the list, but functionally, there are.

    Compared to the other base standard
    sequence containers (deques and
    lists), vectors are generally the most
    efficient in time for accessing
    elements and to add or remove elements
    from the end of the sequence. For
    operations that involve inserting or
    removing elements at positions other
    than the end, they perform worse than
    deques and lists, and have less
    consistent iterators and references
    than lists.

    Compared to other base standard
    sequence containers (vectors and
    deques), lists perform generally
    better in inserting, extracting and
    moving elements in any position within
    the container, and therefore also in
    algorithms that make intensive use of
    these, like sorting algorithms.

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

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

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.