Hello.
I am trying to define a custom Array class using the stl.
the following code gives several compile errors.
template< typename T, typename Allocator=allocator<T> > class Array
{
public:
// typedefs.
typedef T value_type;
typedef Allocator allocator_type;
typedef Allocator::reference reference;
typedef Allocator::const_reference const_reference;
typedef Allocator::size_type size_type;
typedef Allocator::difference_type difference_type;
typedef Allocator:ointer pointer;
typedef Allocator::const_pointer const_pointer;
// forward and reverse iterators.
typedef T* iterator;
typedef const T* const_iterator;
typedef reverse_iterator<iterator, value_type, reference,
pointer, difference_type> reverse_iterator;
typedef reverse_iterator<const_iterator, value_type, const_reference, const_pointer, difference_type> const_reverse_iterator;
// other code.
}; // END template< typename T, typename
// Allocator=allocator<T>>;
these are the errors that i get.
error C2059
error C2238
What am I doing wrong. I looked at the way vector is define and it seems to work?
--------------------Configuration: OpenGL Library - Win32 Debug--------------------
Compiling...
main.cpp
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(48) : error C2059: syntax error : '<'
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(136) : see reference to class template instantiation 'OpenGlArray<T,Allocator>' being compiled
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(49) : error C2238: unexpected token(s) preceding ';'
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(136) : see reference to class template instantiation 'OpenGlArray<T,Allocator>' being compiled
Error executing cl.exe.
main.obj - 2 error(s), 0 warning(s)
I am trying to define a custom Array class using the stl.
the following code gives several compile errors.
template< typename T, typename Allocator=allocator<T> > class Array
{
public:
// typedefs.
typedef T value_type;
typedef Allocator allocator_type;
typedef Allocator::reference reference;
typedef Allocator::const_reference const_reference;
typedef Allocator::size_type size_type;
typedef Allocator::difference_type difference_type;
typedef Allocator:ointer pointer;
typedef Allocator::const_pointer const_pointer;
// forward and reverse iterators.
typedef T* iterator;
typedef const T* const_iterator;
typedef reverse_iterator<iterator, value_type, reference,
pointer, difference_type> reverse_iterator;
typedef reverse_iterator<const_iterator, value_type, const_reference, const_pointer, difference_type> const_reverse_iterator;
// other code.
}; // END template< typename T, typename
// Allocator=allocator<T>>;
these are the errors that i get.
error C2059
error C2238
What am I doing wrong. I looked at the way vector is define and it seems to work?
--------------------Configuration: OpenGL Library - Win32 Debug--------------------
Compiling...
main.cpp
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(48) : error C2059: syntax error : '<'
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(136) : see reference to class template instantiation 'OpenGlArray<T,Allocator>' being compiled
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(49) : error C2238: unexpected token(s) preceding ';'
g:\my projects\c++ projects\cis41 opengl\opengl library\openglvertexarray.h(136) : see reference to class template instantiation 'OpenGlArray<T,Allocator>' being compiled
Error executing cl.exe.
main.obj - 2 error(s), 0 warning(s)