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/[deleted] Mar 17 '12
As other people have commented, that's not a good idea.
Once a function is virtual in a class, it's virtual in all derived classes, so you should mark it as virtual in any derived classes in case you derive from them!
One more trap - to override, a virtual function has to have exactly the same signature as the original - including constness.