Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vc++ 6.0 ans stl.

Status
Not open for further replies.

konbollen

Programmer
Jan 3, 2002
2
US
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::pointer 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)
 
hi !
Please reply me if u find it useful. I am also a learner and I will be a learner throughtout my life.


# include <stdio.h>
//# include <algorithm>
# include <iterator>

using namespace std ;
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::pointer pointer;
typedef Allocator::const_pointer const_pointer;

// forward and reverse iterators.
typedef T* iterator;
typedef const T* const_iterator;

typedef reverse_bidirectional_iterator<const_iterator,
value_type, const_reference, Allocator::const_pointer,
difference_type> const_reverse_iterator;

typedef reverse_iterator<iterator,
value_type, reference, Allocator::pointer,
difference_type> reverse_iterator;

};


void main()
{
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top