You asked if I am allowed to rename any variables, the answer is no. |
I would have thought that you could have control over the variables names in the cpp files, but leave the ones in the header files intact.
My point about the confusion in the names is this: Here are 3 variables names for the same thing -
idCode
,
id
,
pID
. The first 2 are in the header file, which you don't have control over. The last one you should have control over, I would make it
ProductIdCodeArg
in the cpp file parameter if it was in the constructor, or just
ProductIdCode
if in a normal function .
With the names in the header file, it's not good to pre-pend each member with the class name, but IMO it does make sense to use a longer meaningful name for the function parameters and use something similar in the cpp file, because the header file is what the client sees. The client is the coder who includes the header file as part of an API and makes the function call. It's awkward here because you are the one writing the cpp file.
So IMO,
id
is not a good name for a parameter in the header file. If I was the user, I would immediately question
id
for what - lots of things have id's? For example, in
1 2
|
Product* Store::getProductFromID(std::string idCode)
{
| |
So there, the parameter name is the same as the class member name, but I don't know what it means: I shouldn't have to guess, or even go looking somewhere for it.
Given all that, I would ask your question again in detail to your teachers.
The bad news: I'm having a hard time with my productSearch function |
115 116 117 118 119 120 121 122
|
void Store::productSearch(std::string prodName)
{
bool keyWord = false;
for (std::size_t search = 0; search < inventory.size(); search++)
{
for (int x = 0; x < 1; x++) // this only runs once
{
| |