Avoiding virtual functions on embedded target
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a class Player that plays back data from a big block of memory that consists of a number of equal chunks. typedef char chunk_t[100]; typedef struct { chunk_t data[100] } blockOfMemory_t; The Player itself could theoretically work for different layouts and contents of data, so I would like to program it in a re-usable way. To do this, I thought of something like this: class Player { public: Player() { ... } virtual ~Player() { ... } void play() { for (int i = 0; i < getNumChunks(); i++) { if (chunkHasX(i) || chunkHasY(i)) playChunk(i);