Porting from C++: Simulating pure virtual functions

Topics: General
Oct 4, 2012 at 5:07 PM
Edited Oct 4, 2012 at 5:43 PM

I have a base class which implements some functions common to all derived classes but also contains some pure virtual functions which have to be implemented by the deriving classes. What's the preferred way of simulating these pure virtual functions?

I cannot use an interface because I want to define some common functionality in the base class and as far as I understand, interfaces can only contain declarations. Is that correct? Is there an alternative?

Oct 5, 2012 at 4:28 PM

The short answer is currently you can't simulate pure virtual functions, though it's something people are actively asking for.

For the time-being, you can create a base class method with: "throw new Error('abstract method, override in derived class')". 


Oct 5, 2012 at 5:36 PM

Ok, thank you!