C++ list/vector help

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?


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.

C Programming Tutorial for Beginners, Learn C the Hard Way: Practical Exercises on the Computational Subjects You Keep Avoiding (Like C) C or c is the third letter in the English and ISO basic Latin alphabets.Its name in English is cee (pronounced / ˈ s iː /), plural cees.


They are in the std namespace. As are all parts of the C++ standard library. So they are correctly called std::list and std::vector.

They also don't have member functions called add. You may want to look up a C++ reference.

"C" Programming Language: Brian Kernighan, This course will give you a full introduction into all of the core concepts in the C programming Duration: 3:46:13 Posted: Aug 15, 2018 Ç or ç is a Latin script letter, used in the Albanian, Azerbaijani, Manx, Tatar, Turkish, Turkmen, Kurdish, Zazaki, and Romance alphabets. Romance languages that use this letter include Catalan, French, Friulian, Ligurian, Occitan, and Portuguese as a variant of the letter C. It is also occasionally used in Crimean Tatar and in Tajik to represent the /d͡ʒ/ sound. It is often retained in the spelling of loanwords from any of these languages in English, Basque, Dutch, Spanish and other


Vector and list are part of the std namespace. So you should declare your vector and your list like this:

std::list<Bubble> bubbles;
std::vector<Bubble> bubbles_two;

Also, the member function to add an element is push_back.

Why C is so Influential - Computerphile, "C" is one of the most widely used programming languages of all time. Prof Brian Kernighan Duration: 8:26 Posted: Aug 18, 2015 Stock analysis for Citigroup Inc (C:New York) including stock price, stock chart, company news, key statistics, fundamentals and company profile.


list and vector are in the std namespace, and you accordingly must look for them there.

std::vector<Bubble> bubbles;

In either case, you use .push_back to append to the container. When in doubt, you should generally prefer vector.

How easy is it to learn C?, Why is C such an influential language? We asked ardent C fan Professor Brailsford. Brian Duration: 10:50 Posted: Aug 25, 2017 C-- (pronounced cee minus minus) is a C -like programming language. Its creators, functional programming researchers Simon Peyton Jones and Norman Ramsey, designed it to be generated mainly by compilers for very high-level languages rather than written by human programmers.


You are missing the namespace here. Both list and vector is part of the standard namespace which Means that you can include the namespace on a global basis by writing using namespace std; once in the beginning of the file or write std::list and std::vector every where you are using the variables.

How is C programming language still used today?, - and extremely flexible. So flexible, in fact, that as you use the language, you probably go through many different programming styles as you work out how to use the language to produce good, maintainable, reliable code. This is a list of operators in the C and C++ programming languages.All the operators listed exist in C++; the fourth column "Included in C", states whether an operator is also present in C. Note that C does not support operator overloading.. When not overloaded, for the operators &&, ||, and , (the comma operator), there is a sequence point after the evaluation of the first operand.


Learn C, is best choice when you start programming as it is most basic. As well as C and Simula's influences, other languages also influenced this new language, including ALGOL 68, Ada, CLU and ML . Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including classes, derived classes, strong typing, inlining and default arguments.


C Tutorial, learn-c.org is a free interactive C tutorial for people who want to learn C, fast. C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs.C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. This C++ tutorial adopts a simple and practical approach to describe the concepts of C++ for beginners to advanded software engineers.. Why to Learn C++. C++ is a MUST for students and working


C Language - Overview, C programming is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis M. Ritchie at the Bell Telephone  Learn C# programming - for beginning developers, developers new to C#, and experienced C# / .NET developers