Results 1 to 4 of 4

Thread: Problem with the function begin ()

  1. #1
    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.

  2. #2
    Join Date
    May 2008
    Posts
    2,297

    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

  3. #3
    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;

  4. #4
    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.

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,631,200.68200 seconds with 17 queries