Hi,
I would make some other changes too:
I don't like the use of the do loop here, notice you have
quit = true
twice , as well as
while(!quit)
I would make it a
while(!quit) {}
loop as opposed to a do loop. One can use break and continue in loops. At the moment the loops ends if the input is empty, contrary to what is alluded to in the code.
There is no need to use the
this
keyword in this context, member functions have direct access to member variables.
Meaningful variable names are important, they aid understanding and can prevent certain kinds of errors. Every time I see sin, I think of the trig function. A lot of people fall into the trap of over abbreviating their variables identifiers, perhaps something along the lines of
SocialInsuranceNumber
might be better? It's longer, but crystal clear as to what it is.
The
CRA_Account::isEmpty
is misleading too, IMO (In My Opinion) Empty is something that might apply to a container of objects. This function tests the validity of the Social Insurance Number, and doesn't seem to be related to the setEmpty function.
What does CRA and sict mean? I shouldn't have to guess. Reading code should be like reading a story, meaningful names document what is happening. Here is a comical version of what I mean:
http://www.cplusplus.com/forum/lounge/176684/#msg872881
Instead of a set function, consider using a constructor with a member initialization list
1 2 3 4 5 6 7
|
CRA_Account::CRA_Account(const std::string& familyNameArg, // pass std::string by reference
const std::string& givenNameArg, // I use this format when there are multiple parameters
int SocialInsuranceNumberArg)
: // colon introduces member initialization list
lastName(familyNameArg), // try to be consistent with variable names, I would have familyName as the member variable
firstName (givenNameArg)
{} // do validation inside the braces
|
A member initialization list is more efficient because class members are initialized once during creation of the object, as opposed to being initialized with default values first, then reassigning values to them again.
Good Luck !!