← Back to team overview

dolfin team mailing list archive

Re: [HG] Add uBlasKrylovSolver.cpp

 

On Sat, 2006-06-03 at 10:26 +0200, Anders Logg wrote:

> > > > 
> > > > Just done some test and this works fine, but the function cannot be a
> > > > pure virtual function. 
> > > 
> > > Strange. The following compiles for me:
> > > 
> > > class Abstract
> > > {
> > > public:
> > > 
> > >   virtual void foo() = 0;
> > > 
> > > };
> > > 
> > > class Foo
> > > {
> > > public:
> > > 
> > >   virtual void bar(Abstract& abstract) = 0;
> > > 
> > > };
> > > 
> > > class Bar : public Foo
> > > {
> > > public:
> > > 
> > >   void bar(Abstract& abstract) {}
> > > 
> > > };
> > > 
> > > int main()
> > > {
> > >   Bar bar;
> > > 
> > >   return 0;
> > > }
> > > 
> > > Is this not what you mean?
> > > 
> > 
> > This doesn't work for me. Can you send the actual code? I'll try it out.
> > 
> > Garth
> 
> The code above is the actual code. I've attached it. Just compile with
> with
> 
>     g++ main.cpp
> 
> Works for me with g++ 4.0.3.
> 
> /Anders
> 
> 

This works for me, but the problem I have is slightly different. The
problem I have is that the equivalent of Bar::bar (a solver) does't want
"Abstract" as an argument, rather "SomeAbstract" type. I've pasted some
code below. The solution seems be not to make the functions in
LinearSolver pure virtual functons.

Garth


class GenericMatrix
{
public:
  
  virtual void foo() = 0;
  
};


class SomeMatrix : public GenericMatrix
{
public:
  
  
};

class LinearSolver
{
public: 
  
  virtual void bar(GenericMatrix& matrix) = 0;
  
};

class LU : public LinearSolver
{
public:
  
  // This doesn't work
  void bar(SomeMatrix& matrix) {}

  // This works
//  void bar(GenericMatrix& matrix) {}
  
};

int main()
{
  LinearSolver* solver;

  solver = new LU;
  
  return 0;
} 





Follow ups

References