DRAFT document on coding conventions in kde libraries

Thiago Macieira thiago at kde.org
Tue Mar 7 08:39:06 GMT 2006

Leo Savernik wrote:
>I mean simple covariant return values:
>struct A {
>  virtual A *f() { return new A(); }
>struct B : public A {
>  virtual B *f() { return new B(); }
>This works with gcc 2.95, but not with msvc6.

No, I meant complex covariant return values:

struct A {
  int i;
  virtual ~A();
  virtual A *f() { return new A(); }

struct A2 {
  int j;
  virtual ~A2();

struct B: public A2, public A
  virtual B* f() { return new B(); }

gcc 2.95 can't compile this. If you do:
  B *b = new B;
  A *a = b;

Then a == b, but not in value (the pointer values differ).
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

2. Tó cennan his weorc gearu, ymbe se circolwyrde, wearð se cægbord and se 
leohtspeccabord, and þa mýs cómon lator. On þone dæg, he hine reste.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060307/409e337a/attachment.sig>

More information about the kde-core-devel mailing list