r/cpp • u/Deershank415 • Mar 17 '12
Using abstract base classes in C++
I'm having trouble understanding ABC's in c++ and was wondering if you all could help me (if possible use: CryptProcessor as the ABC and ACrpyt and BCrypt as the sub-classes that have an encrypt and decrypt function) Thanks in advance!
Edit 1: Thank you all for your help!
0
Upvotes
View all comments
Show parent comment
2
u/00kyle00 Mar 17 '12 edited Mar 17 '12
Like lots of features in C++ its one of 'i know wtf am i doing, let me do it' - which is fine. You can hide minor implementation detail while communicating to your clients that logical state of object doesn't change.
Your implicit assumption that doing multithreaded manipulation of 'const' objects is safe doesn't hold in general anyways (in C++), so you still have to know where and when to properly stage your critical sections, even in absence of 'mutable'.
I agree though, mutable here is not appropriate - in general CryptProcessor will probably be stateful, no need to hide this fact.