Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++
Expertise: Beginner
Mar 25, 1999

Void Pointer and -> Operator

I am a beginner to C++ and have looked into several resources but still have some questions. Can you tell me what a void pointer is and what it is used for (implementation)? Also, what is the -&#gt; operator?

A void pointer is simply an untyped pointer. That is, a pointer to an unspecified type of variable. Void pointers are usually used where it is not known in advance what data type a pointer will point to.

For example, malloc returns a void pointer because malloc does not know how the allocated memory will be used. Since pointers all use the same amount of memory, a void pointer can be converted to any other type of pointer and, normally, your code will need to type cast a void pointer to a typed pointer before you can use it.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date