Questions tagged as 'vector'

2
answers

In what situations should I allocate a vector dynamically in C ++?

I'm working on a framework code for my work. In one of the functions, it dynamically allocates a std::vector , makes a copy of each node that the object has and returns it to the user: std::vector<Node> *Tree::getAllNodes() {...
asked by 14.12.2013 / 21:31
3
answers

Vector ordering of objects

I'm making an application that sorts a vector of objects. These objects are Cartesian points, defined in the following class: class CartesianPoint { private: int x; // Coordinate X of a pin or a wire part on a cartesian plan int y; //...
asked by 22.12.2016 / 14:20
2
answers

How to use vector to store a class?

Example: class Nome {private: string nome; public: Nome(string nome); virtual void exibirNome() =0; }; class SobreNome: public Nome {private: string nome; public:...
asked by 27.03.2016 / 18:20
1
answer

Vector manipulation in C ++

Is there any problem if I go through a vector by taking its size with vector.size () and then make a for on the vector? I'm asking this question because almost every time I see vectors manipulation, an iterator is used to traver...
asked by 06.02.2016 / 04:39
2
answers

Difference of C / C ++ Array Declarations

What difference and impact do each of these 3 vector statements bring to my code? int n; cin >> n; int* arr = new int[n]; int n; cin >> n; int arr[n]; int n; cin >> n; vector <>int> arr(n);     
asked by 06.05.2017 / 19:31
1
answer

How does it work to use a vector of type struct? (C ++)

I would like help with understanding how to declare a vector of type struct. In the example of the code below I create the struct configcarros and would like to create a vector of the type of this structure and later access num_car and tempodevo...
asked by 28.10.2017 / 03:06
1
answer

Problems eliminating node of a Vector

I have two classes: class CAlbum { private: QString Nome; /**< Nome do Álbum */ QString Descricao; /**< Descrição do Álbum */ QString Diretoria; /**< Diretoria onde se encontra o Álbum */ //QPixmap Imagem; std::vec...
asked by 29.05.2016 / 06:08
2
answers

How to add elements in the "x" position of a std :: vector

How do I add an element to the position I indicate in std::vector ? Not to delete what you already have, but is to add in the middle. Here's an example: Let's suppose that within std::vector has the elements {1,2,3,4,5,6,7,8,9}...
asked by 30.01.2016 / 14:20
3
answers

How to use the vector class of C ++?

Needs the library #include<vector.h> To create it vector <int> c; Question: How do I store values in it and read them?     
asked by 15.03.2016 / 18:32
1
answer

Error in lexar a mathematical equation

I am doing an equation interpreter in C ++ and am trying to show the type of the symbol. But I'm in trouble. I do not know what's wrong. Any constructive tip is welcome. main.cpp : #include <string> #include <iostream>...
asked by 19.06.2018 / 23:01