I learned enums when I learned C and from time to time I keep myself reminding about it and most of the time by re-reading from some source,it occurred to me that this is d
with all said about using enums as symbolic constant, I'd like to emphasize that in C++ using enum in a class gives a very nice, readable and convenient way of encapsulating and exposing class's capabilities, e.g.
class BlockCipher {
public:
enum PaddingOptions { NO_PADDING, DEFAULT_PADDING, ZERO_PADDING /*...*/ }
void encrypt(const std::string& cleartext, std::string& ciphertext,
PaddingOptions pad=DEFAULT_PADDING);
};
int main()
{
std::string clear("hello, world");
std::string encrypted;
BlockCipher encryptor;
encryptor.encrypt(clear, encrypted, BlockCipher::NO_PADDING);
}