[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Forward declaration of template classes
From:       Waldo Bastian <bastian () ens ! ascom ! ch>
Date:       1999-04-28 15:35:11
[Download RAW message or body]

Robert Hagemann wrote:
> 
> Hi all,
> 
> I have the following problem:
> 
> ----- file.h -----------
> 
> class B;
> 
> class A {
> 
> ...
> 
> B* myB_;
> 
> }
> 
> ----- file.cpp ---------
> 
> class B {
> 
> ...
> 
> }
> 
> My favourite programming style is to use only pointers to classes that are
> private members. This way I can use forward declaration as in the example
> above
> and I minimize the coupling between packages/files.
> 
> Now I want to use sth. like this:
> 
> ---- file.h ---------
> 
> class BList;
> 
> class A {
> 
> ...
> 
> BList* mylist_;
> 
> }
> 
> ---- file.cpp ------
> 
> class B {
> ...
> }
> 
> typedef BList QList<B>;
> 
> The compilers chokes. Unfortunately, he did this at home and
> so I don't have the error message handy. ;-(
> 
> Has anybody a clue, what went wrong?

BList is not a class but a typedef. 
You could probably define BList as:

class Blist : public QList<B>
{
  BList(...) : QList<B>(...) { }
}

(Instead of typedef BList Qlist<B>;)

That might be a bit more work though.

Cheers,
Waldo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic