c++ - Disadvantages of passing around functions? -


i'm learning c++ (coming java) , discovered can pass functions around. cool , think immensely useful. thinking on how use , 1 of idea's popped head customizable class.

the best example of train of though customizable classes (code) person class. person have functions pertaining p. later person may pick sword (s), person has access functions pertaining both p , s.

are there limits or performance issues this? sloppy , plain frowned upon?

any insight educational, thanks.

~aedon

there slight performance hit since pointer or reference must dereferenced before calling function.

this advantageous feature. many design patterns , polymorphism depend on pointers functions. check out "visitor design pattern".

another usage table of functions. example, write generic menu engine displays different menus using different functions.

also research "factory design pattern."


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -