delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/01/26/07:15:42

Date: Thu, 26 Jan 1995 18:21:54 +0900
From: Stephen Turnbull <turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp>
To: frbelme AT coulomb DOT uwaterloo DOT ca
Cc: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Pure Virtual Functions in djgpp

A pure virtual function by definition cannot be called.

Presumably you are calling an overload of that function for an object
whose type is implicitly the virtual class:

ie, here the problem is obvious, but there are devious ways to do the
same thing.

class virtual_base {
    int data;
public:
    virtual void vf () = 0;
    };

void func (virtual_base *vbp)
{
    vbp->vf();                // BZZZT!
}

Maybe you can only do polymorphism for classes with the function
defined, and its derivatives.

I don't see why this should be a problem, since you can't instantiate
a pure virtual class.  But there you go; it may be necesary to
implement this way.
-- 
Stephen Turnbull  /  Yaseppochi-gumi  <turnbull AT shako DOT sk DOT tsukuba DOT ac DOT jp>
http://turnbull.sk.tsukuba.ac.jp/   anon FTP: turnbull.sk.tsukuba.ac.jp
Check out Kansai-WWW, too ---------> http://pclsp2.kuicr.kyoto-u.ac.jp/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019