In almost all the books about C and C++, void is introduced as a data type, though comparitively it doesn't seem to be a data type like int and double; Could you clarify this for me?
Thanks in advance
It is just my opinion that it is wrong to call it a type because it doesn't fulfill all the basic requirements of a data type. Again, just my opinion.
It is fallacious to say that void is a type because you can declare a pointer of void just by making note of this ability present in other data types. Just because A implies B, doesn't mean that B implies A. One of the most common fallacies.
If there are OTHER reasons added to back up void as a type, well, then I'd love to hear them. Otherwise I keep my opinion as is.
From what I've read and learned is that void is a data type, or the lack there of. It takes up no memory, that I'm aware of, has no physical value, again, that I'm aware of, and can't be passed, modified, or used in anyway aside from pointers.
I believe this would be open to a debate, but void exists to replace data types when there isn't supposed to be a data type. That is why it's used in functions. We don't always need a data type returned.
void is a type. It is not an arithmetic type like int and double. It is not a scalar type, like pointer or enum, it is not a compound type like reference or function. But it is a distinct fundamental type.