How does 'void*' differ in C and C++?Before learning the differentiating factor of void functions in C and C++ programming language, let us see a few examples and deeply understand the void function where it is used, use cases we can draw etc. Void funThe void, as the name suggests, there is nothing it owes to any entity in programming. The void function, when called, will not return anything to the primary position; the control jumps to where the process is called after finishing the operation allowed in the process, which can either be calculation, recursion or printing anything to the display screens and then we will look at the play of pointers and examine How does 'void*' differ in C and C++? C++ void function-1C++ void function-2Output: //output_is_for_both_C++_codes_written_above As we expect it to perform, the void function has returned the void to the central control. C void FunctionOutput: C void function print statement 1C void function print statement 1 perfection in programming in C." How does 'void*' differ in C and C++?A c programming language allows a void* pointer to be assigned to any pointer type without a cast, whereas C++ does not. We have to typecast the void* pointer in C++ explicitly. Let us look at the example below; the following is valid in C but not C++: Similarly, To make the above code compile in C++ as well, we have to use explicit casting, as shown below, |
JavaTpoint offers too many high quality services. Mail us on h[email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected].
Duration: 1 week to 2 week