0

I have the following classes where I try to acces a protected member of the Base class but I get an error in eclipse "Field Factorized could not be resolved". Can someone explain to me what am I doing wrong? Why can't I access to the variable mFactorized ??

BASE CLASS

template <typename ValueType>
class AbstractDirectLinearSolver{
protected:
    bool mFactorized;
public:
    //Constructors, destructor
    AbstractDirectLinearSolver(){
        mFactorized = false;
    }

    virtual ~AbstractDirectLinearSolver();

    //Methods
    virtual void Solve(Vector<ValueType>& x, const Vector<ValueType>& b) const = 0;
    virtual void Factorize(AbstractMatrix<ValueType>& A) = 0;
};

DERIVED CLASS

#include "AbstractDirectLinearSolver.hpp"

template<typename ValueType>
class CholeskySolver: public AbstractDirectLinearSolver {
private:
    AbstractMatrix<ValueType> *mR; //Pointer = Abstract class NOT ALLOWS instantiation !!
public:
    CholeskySolver() {
        mR = NULL;
    }

    ~CholeskySolver() {
        if (this->mFactorized) {  //ERROR HERE
            delete mR;
        }
    }

    void Solve(const Vector<ValueType>& x, const Vector<ValueType>& b) {
        Vector<ValueType> y(mR->ApplyLowInv(b));
        x = mR->ApplyLowerTransponse(y);
    }

    void Factorize(AbstractMatrix<ValueType>& A) {
        if (mR != NULL)
            delete mR;
        mR = NULL;
        A.CholeskyFactorization(mR);
        this->mFactorized;           //ERROR HERE
    }
};
BRabbit27
  • 6,333
  • 17
  • 90
  • 161

2 Answers2

2

You are trying to inherit from a class template, rather than a class. Change the class header to:

template<typename ValueType>
class CholeskySolver: public AbstractDirectLinearSolver<ValueType>
                                                       ^^^^^^^^^^^

It looks like the compiler bails out after complaining that mFactorized wasn't a member (because it didn't know about the base class), but before complaining that the base-class specifier was invalid.

If you were to comment out the problematic lines, then you'd get a slightly better (though still rather confusing) error: expected class-name before ‘{’ token.

Mike Seymour
  • 249,747
  • 28
  • 448
  • 644
0
if (this->Factorized) 

should be

if (this->mFactorized)

The second error...

this->mFactorized;           //ERROR HERE

apart from the fact that it doesn't do anything.... I don't think there should be a problem.

Caribou
  • 2,070
  • 13
  • 29
  • Yes, the first one was a typo, but then eclipse keeps marking it as an error that says `Field Factorized could not be resolved`. I think there's no problem but why is it marked as one? – BRabbit27 Nov 23 '12 at 11:39
  • if you miss out the `this->` part is it still highlighted? Also could it need to be re-indexed. Other than that I don't know Eclipse well enough I'm afraid. – Caribou Nov 23 '12 at 11:42