abstract methods

Top  Previous  Next

What is translated > abstract methods


Like Delphi also C++ knows abstract methods. So till version 1.4.3 Delphi2Cpp  did the most natural way of translation, as in the example:


procedure foo; virtual; abstract;


void __fastcall foo() = 0;


But opposed to Delphi. in C++ no objects can be created from classes with abstract methods. To allow this creation in C++ too, the method is now defined such, that it throws an exception, if it is called:


void __fastcall foo ()

{ throw std::runtime_error("abstract function called"); }


If the Delphi code was correct, this method never will be called.


#include <stdexcept>


where std::runtime_error is defined is included automatically.



This page belongs to the Delphi2Cpp Documentation

Delphi2Cpp home  Content