Is it possible to implement a monkey patch in C ++? Or any other similar approach to this?
Thanks.
To add to the other answers, think that any function that is opened through a shared object or DLL (depending on the platform) can be overridden at run time. Linux provides an environment variable LD_PRELOADthat can specify a shared object to load after all others, which can be used to override arbitrary function definitions. This is actually the best way to provide an “object layout” for unit testing purposes, as it is not invasive. However, unlike other forms of correction of monkeys, keep in mind that such a change is global. You cannot indicate that one particular call is different from another without affecting other calls.
LD_PRELOAD
, - .
, , - . , , #include .
, " " - A B OS S, -, S , . ( , ).
, , . , VC, #import , _bstr_t . _bstr_t , , #define ' _bstr_t #import.
#import
_bstr_t
#define
- VMT - -, . , VMT. , , , . , C++. / .
, / COM . , " ", .
, , . , - ( , ). , , . , (, LD_LIBRARY_PATH) - , .
valgrind, , ( , ) .
, " " , ++ :
const_cast
const
#define private public
use Parent::protected_field
, , , , , , .
, , ++...
Source: https://habr.com/ru/post/1720392/More articles:Разработка игр. Как делаются более одного цикла игры? - language-agnosticUsing Rack :: Session :: Datamapper - ruby | fooobar.comSome questions about the structure and array of C ++ - c ++Organizing vim plugins in separate directories - vimCan I get table names from a SQL query using Perl DBI? - sqliteC: An array declared inside the can not function exceeds ~ 8 MB of memory. - cCall hierarchy and / or data stream for Scala - javaDllNotFoundException when trying to “fix” LuaInterface, but why? - c #How to get Zend_Config used by Zend_Application? - zend-frameworkhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1720397/add-strings-to-array-php&usg=ALkJrhhoy3X3J6u45Sd7HO8Ra99TODcuBAAll Articles