help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with standard template library


From: Paul Pluzhnikov
Subject: Re: Problem with standard template library
Date: 29 Sep 2004 22:36:17 -0700
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

Carl Flarity <spamforcarl@yahoo.com> writes:

> I'm new at using gcc and new at using templates.
> Please help me figure out what I'm doing wrong in the
> following program. 

The standard STL containers reside in a namespace 'std'.

> Is there something additional I
> need to do to let the compiler know that vector is a
> template?

No, but you need to let it know that it is the 'std::vector'
you want, not something else.

Three ways to do so: 
1. add 'using namespace std;' somewhere before the first use, or
2. add 'using std::vector;' or 
3. explicitly specify std scope, like so:

> #include <vector>
> int main(void){
> 
        std::vector<int> v;
> 
> }

Current consensus seems to be that (2) and (3) are preferred.

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]