I have a buffer char(i.e. byte) that I send over the network. At some point in the future I will want to switch the buffer to another type, for example, unsigned charor short. I was thinking of doing something like this:
typedef char bufferElementType;
And whenever I do something with a buffer element, I declare it as bufferElementType, rather than char. Thus, I could switch to another type by changing this typedef (of course, it would not be so simple, but at least it would be easy to determine the places that need to be changed ... there will be bufferElementTypenearby, nearby).
Is this a valid / good use of typedef? Isn't that worth the problem? Will it have a headache at some point in the future? Are programmers going to support programmers to hate me?
I read When should I use Typedef in C ++ , but no one explained it.
source
share