There is no need to declare class members private if they appear at the top of your class. However it is customary to declare public members first so that users (yourself included) can see what they can work with without having to read through class internals.
Don't declare andan empty constructor or destructor. If you are going to then at least declare it
= default
.system("CLS")
is non-standard and non-portable. It is generally considered bad-practice to call into the OS unless you have good reason too.In C++ it is customary to put the identifier with the type. ie
Caesar* obj
as opposed to the variable.Don't use
new
ordelete
. If you are going to use pointers then you should probably started using smart pointers. However.Don't use pointers when you don't need them. In your
main
you absolutely could have calledCaesar caesar;
.Why do your function calls require you to pass the object back to itself? any information that the instance contains is available to itself at any time. That includes private member data.
Using
.eof()
the way you do produces a bug. The loop will iterate one more time after the end of file is reached. ItThis is betterbecause eof() does not get set tobreak
from a loop whentrue until it reachestries to read.eof()
past the end of the file. I found this snippet when searching for a better way to do this:while(true) { if (file.eofpeek()) { break; } . . . //rest of loop != }EOF)
avoid using
std::endl
. This performs a flush of the stream which you typically don't want or need and can cause performance issues.\n
is sufficient and adding in astd::flush
if you need to flush the stream will make it clear you meant to do it.