Total members 11894 |It is currently Fri Nov 22, 2024 8:40 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Getting the front of vectors using C++
cpp code
#include <iostream>
using std::cout;
using std::endl;

#include <vector> // vector class-template definition
#include <algorithm> // copy algorithm
#include <iterator> // ostream_iterator iterator
#include <stdexcept> // out_of_range exception

int main()
{
int array[ 6 ] = { 1, 2, 3, 4, 5, 6 };
std::vector< int > integers( array, array + 6 );
std::ostream_iterator< int > output( cout, " " );

integers.push_back( 2 );
integers.push_back( 3 );
integers.push_back( 4 );

cout << "Vector integers contains: ";
std::copy( integers.begin(), integers.end(), output );

cout << "\nFirst element of integers: " << integers.front();

return 0;
}

/*
Vector integers contains: 1 2 3 4 5 6 2 3 4
First element of integers: 1
*/




_________________
Please recommend my post if you found it helpful


Author:
Beginner
User avatar Posts: 95
Have thanks: 2 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : vector front
 queue of objects keep track of the front and rear     -  
 C++ Vector capacity     -  
 Iterator on Vector     -  
 Vector class     -  
 Data Structures: Vector     -  
 count elements in a vector     -  
 Write Vector list to File     -  
 Support Vector Machine coding on Matlab...     -  
 Move image in front of a background image     -  



Topic Tags

C++ Data Structures






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com