I'm reading 'C++ For Dummies 7th Edu' and I'v ran into this little snipet that's confusing me.
BOOK
You can add const-ness, however, as in the following
void fn(char* pName)
{
// declare following is allowed even though
// declared Student(const char*)
Student s(pName);
// ...do whatever...
}
The function fn() passes a char* string to a constructor that promises to treat the string as if it were a constant.
/BOOK
The example before this used a constructor that was almost identical Student(const* pName)
. The only difference I see is that the Student constructor in the fn() function doesn't have a variable name given to hold it's argument, I didn't think that was legal. I don't see what the book is driving at, all this short snippet did was to place the Student object creation in a regular function and leave out the variable name of the paramater in the student constructor? What am I missing here? Thanks.