Click here to Skip to main content
15,881,812 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionClist Find question Pin
ForNow29-Apr-22 3:12
ForNow29-Apr-22 3:12 
AnswerRe: Clist Find question Pin
Richard Andrew x6429-Apr-22 3:34
professionalRichard Andrew x6429-Apr-22 3:34 
GeneralRe: Clist Find question Pin
ForNow29-Apr-22 3:58
ForNow29-Apr-22 3:58 
GeneralRe: Clist Find question Pin
Richard Andrew x6429-Apr-22 4:02
professionalRichard Andrew x6429-Apr-22 4:02 
GeneralRe: Clist Find question Pin
ForNow29-Apr-22 4:15
ForNow29-Apr-22 4:15 
GeneralRe: Clist Find question Pin
Richard Andrew x6429-Apr-22 4:17
professionalRichard Andrew x6429-Apr-22 4:17 
Questionvector, adding things Pin
Calin Negru25-Apr-22 18:42
Calin Negru25-Apr-22 18:42 
AnswerRe: vector, adding things Pin
CPallini25-Apr-22 20:21
mveCPallini25-Apr-22 20:21 
Actually, as its name suggestes, push_back adds an item at the back of the vector.
Try the following sample code in order to see insert in action:
C++
#include <iostream>
#include <vector>
using namespace std;

int main()
{
  vector <int> v;

  v.push_back(1);
  v.push_back(2);
  v.push_back(3);

  cout << "v-front " << v.front() << "\n";
  cout << "v-back " << v.back() << "\n";

  v.insert(v.begin(), 4); // insert '4' before the first item: now '4' is the new front of 'v'

  cout << "v-front " << v.front() << "\n";

  v.insert(v.end() - 1, 5); // insert '5' just before the last item (back) of 'v', now '5' is the second-last item of 'v'

  v.insert(v.end(), 6); // insert '6' just before the 'pass-the-end' of 'v', that is '6' is the new back of 'v'.

  for (auto x : v) // show, in order, all 'v' items
    cout << x << " ";
  cout << "\n";
}

"In testa che avete, Signor di Ceprano?"
-- Rigoletto

GeneralRe: vector, adding things Pin
Calin Negru25-Apr-22 21:42
Calin Negru25-Apr-22 21:42 
GeneralRe: vector, adding things Pin
CPallini25-Apr-22 21:43
mveCPallini25-Apr-22 21:43 
AnswerRe: vector, adding things Pin
Randor 26-Apr-22 16:03
professional Randor 26-Apr-22 16:03 
GeneralRe: vector, adding things Pin
Calin Negru26-Apr-22 23:09
Calin Negru26-Apr-22 23:09 
QuestionWhy won't VS2015 let me compile? Pin
charlieg21-Apr-22 8:17
charlieg21-Apr-22 8:17 
AnswerRe: Why won't VS2015 let me compile? Pin
Victor Nijegorodov21-Apr-22 9:14
Victor Nijegorodov21-Apr-22 9:14 
GeneralRe: Why won't VS2015 let me compile? Pin
charlieg21-Apr-22 9:51
charlieg21-Apr-22 9:51 
GeneralRe: Why won't VS2015 let me compile? Pin
Victor Nijegorodov21-Apr-22 10:25
Victor Nijegorodov21-Apr-22 10:25 
GeneralMessage Closed Pin
25-Apr-22 20:44
professionalMasudul Herry25-Apr-22 20:44 
GeneralRe: Why won't VS2015 let me compile? Pin
Victor Nijegorodov26-Apr-22 1:54
Victor Nijegorodov26-Apr-22 1:54 
GeneralRe: Why won't VS2015 let me compile? Pin
Richard Deeming26-Apr-22 2:41
mveRichard Deeming26-Apr-22 2:41 
GeneralRe: Why won't VS2015 let me compile? Pin
Richard MacCutchan26-Apr-22 2:41
mveRichard MacCutchan26-Apr-22 2:41 
AnswerRe: Why won't VS2015 let me compile? Pin
Greg Utas21-Apr-22 12:13
professionalGreg Utas21-Apr-22 12:13 
GeneralRe: Why won't VS2015 let me compile? Pin
charlieg25-Apr-22 0:56
charlieg25-Apr-22 0:56 
JokeRe: Why won't VS2015 let me compile? Pin
Randor 21-Apr-22 14:04
professional Randor 21-Apr-22 14:04 
GeneralRe: Why won't VS2015 let me compile? Pin
charlieg22-Apr-22 0:19
charlieg22-Apr-22 0:19 
AnswerRe: Why won't VS2015 let me compile? Pin
charlieg22-Apr-22 0:29
charlieg22-Apr-22 0:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.