Hi,

I'm having difficulty finding a way to implement part of a matrix library I'm writing. Here's a distilled version of the code, to demonstrate the problem:

Code:
class Vector {
public:
  virtual Vector *getTranspose() = 0;
}

class RowVector : public Vector {
public:
  virtual ColumnVector *getTranspose();
}

class ColumnVector : public Vector {
public:
  virtual RowVector *getTranspose();
}
The problem, as you can probably see, is one of forward declaration. I want to override the getTranspose() method of Vector to return a pointer to a RowVector or ColumnVector as appropriate using covariate return types, which is perfectly legal. But the ColumnVector and RowVector classes need to be aware of each other.

Clearly, if I were not dealing with covariate return types, I could just insert a forward declaration of ColumnVector at the top somewhere. But for the above snippet to compile, the compiler needs to be aware not only that ColumnVector exists, but that it inherits from Vector - and I can't find a way to declare this fact, because ': public Vector' is part of the definition of ColumnVector, not its declaration.

Any ideas? Am I missing something? I feel sure that I must be, because I'd be able to implement this interface without any problems in a whole bunch of other OO languages...

Cheers
cooperised