Error C2535 With vector ("member function already defined")

Tech-Archive recommends: Fix windows errors by optimizing your registry



I'm unable to compile the most trivial program using a vector with Visual
Studio 2003 (version 7.1.3008).

It worked fine with 6.0.

-------------------------------------
#include "StdAfx.h"
#include <vector>

class MyTest
{
public:
MyTest(void) {};
~MyTest(void) {};
};

static void func () {
std::vector<MyTest> myVec;
MyTest myTest;
myVec.push_back(myTest);
}

-------------------------------------
------ Build started: Project: VectorTest, Configuration: Debug Win32 ------

Compiling...
MyTest.cpp
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xmemory(87) :
error C2535: 'std::allocator<_Ty>::pointer
std::allocator<_Ty>::address(std::allocator<_Ty>::reference) const' : member
function already defined or declared
with
[
_Ty=const MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\xmemory(81) : see declaration of
'std::allocator<_Ty>::address'
with
[
_Ty=const MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\memory(257) : see reference to class template instantiation
'std::allocator<_Ty>' being compiled
with
[
_Ty=const MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\vector(878) : see reference to function template
instantiation 'void
std::_Uninitialized_fill_n<std::vector<_Ty>::pointer,std::vector<_Ty>::size_type,_Ty,std::_Vector_val<_Ty,_Alloc>::_Alty>(_FwdIt,_Diff,const
_Tval &,_Alloc &)' being compiled
with
[
_Ty=MyTest,
_Alloc=std::allocator<MyTest>,
_FwdIt=std::vector<MyTest>::pointer,
_Diff=std::vector<MyTest>::size_type,
_Tval=MyTest
]
c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\vector(877) : while compiling class-template member function
'std::vector<_Ty>::pointer
std::vector<_Ty>::_Ufill(std::vector<_Ty>::pointer,std::vector<_Ty>::size_type,const _Ty &)'
with
[
_Ty=MyTest
]
c:\Documents and Settings\sjohnson\My Documents\Visual Studio
Projects\AuthorizationService\VectorTest\MyTest.cpp(22) : see reference to
class template instantiation 'std::vector<_Ty>' being compiled
with
[
_Ty=MyTest
]

Build log was saved at "file://c:\Documents and Settings\sjohnson\My
Documents\Visual Studio
Projects\AuthorizationService\VectorTest\Debug\BuildLog.htm"
VectorTest - 1 error(s), 0 warning(s)
-------------------------------------

.



Relevant Pages

  • Re: Error C2535 With vector ("member function already defined")
    ... Studio 2003. ... static void func { ... MyTest myTest; ... not include any mention of the address member function. ...
    (microsoft.public.vc.stl)
  • Re: structs
    ... > itself in Visual Studio 6 it compiles fine with no errors, ... > try and compile it on the command line (still using the studio compiler, ... > executable), I get errors where the struct is used, i.e. ...
    (comp.lang.cpp)
  • structs
    ... Our aim is to modify the C/C++ code so that the interface sends an receives ... itself in Visual Studio 6 it compiles fine with no errors, ... try and compile it on the command line (still using the studio compiler, ...
    (comp.lang.cpp)
  • RE: First Visual Studio C++.net Project
    ... Here's the out of my compile: ... Command Lines Creating temporary file "c:\Documents and ... Settings\louis.AZALEA\My Documents\Visual Studio ... Creating temporary file "c:\Documents and Settings\louis.AZALEA\My ...
    (microsoft.public.dotnet.languages.vc)
  • Re: VC2008 Bug: optimising static_cast to a virtual base gives C1001 internal compile error
    ... Submit a bug report on the MS Connect site, ... was reproducing it by right-clicking on the .cpp file and chosing ... "compile" which just compiles the individual file... ...
    (microsoft.public.vc.language)