[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Virtual question



On Saturday 2002-12-07 14:02, Miguel A. Osorio wrote:

> class Base {
>
>   private:
>     int base_data;
>
>   public:
>     virtual void print_data(void) { printf("%d", base_data); }
>
> }
>
>
> 	And then derive a class like:
>
>
> class Derived : public Base {
>
>   private:
>     int derived_data;
>
>   public:
>     void print_data(void) { printf("%d - %d", base_data, derived_data);
> }
>
> }
>
>
> 	Does the whole polymorphism deal only work when I have pure virtual
> functions, or does it still work in this case?

Works fine with this example. Pure virtual methods are just virtual 
methods that are not implemented in the base class.

-- 
Christian Reiniger

Don't panic--you can always eat at Milliways.
 - Zaphod Beeblebrox