You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is part question, part issue. I don't really understand the design decision to make functions in derived classes virtual. For example, each layer class derived from Layer has all of its functions (which override the ones in Layer) declared as virtual as well. Why are things done this way? Is the polymorphism here used anywhere beyond the initially derived classes themselves? I think there's typically a (very) slight effect on performance with virtual functions, so it might make sense to use virtual functions only when we know the polymorphism is going to be used.
The text was updated successfully, but these errors were encountered:
I have wondered about this myself, so I did a little searching.
Virtual methods are implicitly virtual in derived classes; there is no "additional" penalty from using the optional keyword virtual when overriding a method. The use of the keyword is a stylistic choice; following the Google C++ style guide, we include it so that all virtual methods are explicitly noted as such.
This is part question, part issue. I don't really understand the design decision to make functions in derived classes
virtual
. For example, each layer class derived fromLayer
has all of its functions (which override the ones inLayer
) declared asvirtual
as well. Why are things done this way? Is the polymorphism here used anywhere beyond the initially derived classes themselves? I think there's typically a (very) slight effect on performance with virtual functions, so it might make sense to use virtual functions only when we know the polymorphism is going to be used.The text was updated successfully, but these errors were encountered: