Re: error in compiling 2002 code in 2005
p2 schrieb:
On Apr 24, 3:20 pm, David Wilkinson <no-re...@effisols.com> wrote:
p2 wrote:
Hi
i have code build in visual studio 2002 .
when i open that code in 2005 it pops up conversion wizard..
it convert successfully .
but when i build it gives error
is something is missing ?
it gives error in "Iterator" keyword?
Errors ::
warning C4346: 'Iterator::difference_type' : dependent name is not a
type
prefix with 'typename' to indicate a type
see reference to class template instantiation
'iterator_traits<Iterator>' being compiled
[...]
the code is as follows :: //following is the code for above errors
template< class Iterator >
struct iterator_traits
{
typedef Iterator::difference_type difference_type;
typedef Iterator::value_type value_type;
typedef Iterator::pointer pointer;
typedef Iterator::reference reference;
typedef Iterator::iterator_category iterator_category;
};
The error message is correct, what you post here is invalid C++. The error
message tells you already the solution, you need to add the typename keyword:
> typedef typename Iterator::difference_type difference_type;
But I assume your problem is something totally different.
The code you post is usually part of the C++ standard library. This library is
part of visual studio 2005. If you just take a new VS2005 project than these
errors should not happen.
So I guess you have more than one standard library installed on your computer,
and you have messed up the visual studio include paths. But that is hard to tell
because you still did not give us the full error message (including file name
and line number!).
Do you use a different C++ standard library? Have you added some other
compiler's include paths to your project settings? Do you use the stdandard
library or the stl? DO you include <vector> or <vector.h>?
Norbert