Re: pure virtual and template
On 27 juuni, 21:09, Philipp Kraus <philipp.kr...@flashpixx.de> wrote:
Hello,
I try to use abstract classes (only pure virtual function) with
templates for creating my my class structures, but it doesn't work:
my base class:
template<typename T> class distance {
enum matrixRowType { row = 0, column = 1 };
public :
virtual blas::vector<T> calculate( const blas::matrix<T>&, const
blas::matrix<T>&, const matrixRowType& ) const = 0;
virtual blas::vector<T> calculate( const blas::matrix<T>&, const
blas::matrix<T>&, const blas::matrix<T>&, const matrixRowType& ) const
= 0;
virtual blas::vector<T> abs( const blas::vector<T>& ) const = 0;
virtual T calculate( const blas::vector<T>&, const
blas::vector<T>& ) const = 0;
virtual T calculate( const blas::vector<T>&, const
blas::vector<T>&, const blas::vector<T>& ) const = 0;
virtual ~distance() = 0;
};
Post compiling code. Why should we reinvent your usings and #includes?
Now I try to implement these method in my real class with:
template<typename T> class euclid : public distance<T> {}
The ";" is missing at end.
Post compiling code. Why should we reinvent what you really did?
The compiler shows messages and errors. The blas namespace is used for
boost ublas structurs and I get errors from there like:
error: no type named 'property_map' in .....
No it does not. If i add everything that was missing it compiles. But
wher do i know what you did miss since you did not post what you had?
Post code that fails with your errors.
If I remove the "public distance<T>" from my euclid class everything
works find. In my opinion I have created a pure virtual class for using
them as a master class. In my subclasses are guaranteed that the
methods all implementated. I need the templates because the types of my
classes are float, double or long double, so I don't want to implement
more classes.
What is my mistake in my design and how I can solve the problems?
Only mistake i see is that you do not know how to ask for help in
usenet. The FAQ explains how to do it.