What's the best way to force the user of a C++ function to acknowledge the semantic meaning of parameters that are numerical constants?

后端 未结 7 2091
故里飘歌
故里飘歌 2021-02-13 15:27

I\'d like to write function interfaces that force the user to acknowledge the semantic meaning of built-in constants. For example, I\'d like to take

void rotate(         


        
7条回答
  •  囚心锁ツ
    2021-02-13 15:39

    This is the perfect way to do this. Thats what makes C into C++. Using classes where you need them and encapsulate data. It does not make program any notable slower, since compiler does all the optimizations.

提交回复
热议问题