virtual inline vs inline

Jonathan Wakely
Mon Nov 4 14:51:00 GMT 2013

On 4 November 2013 13:33, Norbert Dajka wrote:
> Hello,
> I would like to know, if there is any difference (in allocated memory
> space) between defining a function inline in the class declaration
> (with the inline word), and defining a function inline explicit after
> the class declaration.

There is no difference.

> In addition, does anybody know, why a previously only inline declared
> function takes up more memory space, if it's declared virtual inline
> (even if the classes to which the declaring class of the function is a
> parent class doesn't have their own implementation)?

Because virtual functions need additional metadata in the class,
specifically in the ABI used by G++ the class must have a pointer to
the vtable (if it didn't have one already) and the vtable will have an
additional entry for the virtual function.

More information about the Gcc-help mailing list