A
Anna Smidt
Hello,
Can somebody tell me how to rewrite this in order to have the compiler
compile this without crashing?
Thanks a lot!
Anna
#ifndef cvec_hpp
#define cvec_hpp
#include<vector>
using namespace std; // so "vector" below is actually "std::vector", etc.
template<class T> class cvec : public vector<T>
{
public: // typenames like iterator are also inherited
typedef typename cvec::size_type size_type;
typedef typename cvec::iterator iterator;
typedef typename cvec::difference_type difference_type;
typedef typename cvec::reference reference;
typedef typename cvec::const_reference const_reference;
cvec() {}
cvec(size_type n, const T& value = T()): vector<T>(n, value) {}
cvec(iterator i, iterator j): vector<T>(i, j) {}
reference operator[](difference_type i)
{
DASSERT(i >=0 && i < static_cast<difference_type>(this->size()));
return vector<T>:
perator[](i);
}
const_reference operator[](difference_type i) const
{
DASSERT(i >=0 && i < static_cast<difference_type>(this->size()));
return vector<T>:
perator[](i);
}
};
#endif // cvec_hpppp
Can somebody tell me how to rewrite this in order to have the compiler
compile this without crashing?
Thanks a lot!
Anna
#ifndef cvec_hpp
#define cvec_hpp
#include<vector>
using namespace std; // so "vector" below is actually "std::vector", etc.
template<class T> class cvec : public vector<T>
{
public: // typenames like iterator are also inherited
typedef typename cvec::size_type size_type;
typedef typename cvec::iterator iterator;
typedef typename cvec::difference_type difference_type;
typedef typename cvec::reference reference;
typedef typename cvec::const_reference const_reference;
cvec() {}
cvec(size_type n, const T& value = T()): vector<T>(n, value) {}
cvec(iterator i, iterator j): vector<T>(i, j) {}
reference operator[](difference_type i)
{
DASSERT(i >=0 && i < static_cast<difference_type>(this->size()));
return vector<T>:

}
const_reference operator[](difference_type i) const
{
DASSERT(i >=0 && i < static_cast<difference_type>(this->size()));
return vector<T>:

}
};
#endif // cvec_hpppp