typedef char * PSTR;
void Print (char *szToPrint);
void Print (PSTR szToPrint);
"The preceding two fxns have identical arguments. PSTR is an acronym for type "char*". In Member scope, this code generates an error."
typedef char * PSTR;
void Print (char *szToPrint);
void Print (PSTR szToPrint);
"The preceding two fxns have identical arguments. PSTR is an acronym for type "char*". In Member scope, this code generates an error."
PSTR is typedef'ed to mean char *. So the second function prototype is taken to mean this:
Problem: The first function prototype is identical to this.Code:void Print (char *szToPrint);
Member scope.... This has to do if you're writing functions for classes. The compiler freaks out if you make the above type of function declarations that resolve to the same signature.
No, it's an alias. Meaning you can go through your code and replace every occurence of PSTR with char* and the meaning will not change. (OK, that's not quite true, but the edge case where it isn't is not important right now.)PSTR is an acronym for type "char*".
As for the member scope thing ...
Is this code valid? Yes. Both lines are declarations for the same function. A function may be declared more than once.Code:void foo(); void foo();
But in member scope:
it is invalid. For some reason, declaring the same member function twice is not allowed.Code:class bar { void foo(); void foo(); };
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
Those really helped