Skip to main content
GameDev.net gamedev.net
🔒 Locked

Virtual Functions question

Started by pschmitt Apr 24, 2003 at 6:50 PM 2 replies 300+ views
Original Post
pschmitt
pschmitt
Hi, This is my class structure: Base interpolation class linear interpolation class (derived from base interpolation class) hermite spline interpolation class (derived from base interpolation class) Anyway, in my program, you can read a textfile and call a load function. linear.load() takes 2 parameters hermite.load()takes 3 parameters I tried simply overloading my virtual function in the base interpolation class, but I get a few errors: Hermite: cannot instantiate abstract class due to following members: See declaration of "hermite" see declaration of "Load" warning C4259: 'void __thiscall Interp::Load(class ifstream &,int,class point *)' : pure virtual function was not defined Linear: Cannot instantiate abstract class due to following members: See declaration of "linear" See declaration of "load" warning C4259: 'void __thiscall Interp::Load(class ifstream &,int,class point *,class vector *)' : pure virtual function was not defined how do I declare my overloaded virtual functions inside of the base interpolation class? Thanks, -pete [edited by - pschmitt on April 24, 2003 7:51:46 PM] [edited by - pschmitt on April 24, 2003 7:52:28 PM]
cozman
cozman
If it''s pure virtual it must be correctly implemented.. if you are going to add parameters then it can''t be pure virtual, but you could still make it virtual.
Sneftel
Sneftel
What you''re trying to do makes no sense.

The ONLY reason to use virtual functions is so that you can call a function on a base class pointer without knowing what derived class it points to. But if you''re passing in different arguments, then you must know!

What are you trying to gain by using virtual functions?


How appropriate. You fight like a cow.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.