design pattern : adding new function to pre-written class in library

I have a library provided by the vendor. All i have is header files and library files.

Library contains the class Shape and there is whole hierarchy tree (i mean classes which derive from this base class).

Q : Now i want to add some function “getArea” (not originally present in the class or any of its derived class) in the class “Shape” , i don't have the source code.
Last edited on
Short answer: do not do that.

If possible, use a freestanding function. Or use wrapper to extend Shape class.

Alternatively get library source, modify it and recompile.
Topic archived. No new replies allowed.