Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-11-2009
Member
 
Join Date: Aug 2009
Posts: 36
Problem with the function begin ()

I'm experiencing the different functions offered by the STL :
Code:
 # include <iostream> 
 # include <vector>
 # include <algorithm>

 using namespace std;

 int main (void)
 (
     vector <int *> test;
     int a = 0;
     while (a <10)
     (
         test. push_back (& a);
         court <<test [a] <<endl;
         a + +;

     )
     cout <<test. begin () <<endl;

     return 0;
 )

I compile and get a error message on the line:: No match for 'operator <<'
Does someone can tell me where is my mistake? what's missing? Thank you in advance for your answers.
Reply With Quote
  #2  
Old 21-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Problem with the function begin ()

C++ STL comes with a rich set of such components that aid in storing collection of values. To request an iterator appropriate for a particular STL templated class, you use the syntax :
Code:
std::class_name<template_parameters>::iterator name
Reply With Quote
  #3  
Old 21-11-2009
Member
 
Join Date: Jan 2009
Posts: 199
Re: Problem with the function begin ()

iterators are a type (actually an object) in themselves. <int> vector:: iterator it declares an iterator on a vector of integer. This iterator is called "it".You should follow a tutorial that explains what the iterators, you'd understand.

In fact machin.begin () that you return an iterator to the first object, An iterator "reference" object. To access the object must be:
Code:
court <<* test. begin () <<endl;
Reply With Quote
  #4  
Old 21-11-2009
Member
 
Join Date: Dec 2008
Posts: 177
Re: Problem with the function begin ()

Vectors iterators are usually implemented as pointers. Passing over all the elements of a vector is simple, and is usually done using subscripts instead of an iterator. The type of iterator is different for each container. For example the type of iterator vector <int>, <char> vector, vector <string> ... are different.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Problem with the function begin ()"
Thread Thread Starter Forum Replies Last Post
File does not begin with %pdf- Jahbriel Windows XP Support 3 13-05-2011 01:38 AM
How to begin with MATLAB? Jacques25 Software Development 3 18-01-2011 07:57 AM
Tips to begin sim game Spiero Video Games 5 18-02-2010 10:38 AM
Difference between begin () and rbegin () Antarjot Software Development 3 20-11-2009 02:25 PM
Install cannot begin, says a driver is missing!!! subhaash Vista Setup and Install 3 30-04-2007 08:07 PM


All times are GMT +5.5. The time now is 02:41 PM.