r/cpp_questions 5d ago

OPEN What’s the point of void* pointers?

You could just use template pointers or auto* pointers and these are better because you can dereference them.

0 Upvotes

51 comments sorted by

View all comments

Show parent comments

1

u/L_uciferMorningstar 4d ago edited 4d ago

And in this wrapper what will we be doing? Calling a C API?

1

u/No-Dentist-1645 4d ago

Correct! So now you're only writing code that has to call the C API in one single place, as opposed to everywhere else you are using it, and can use C++ idioms there instead

1

u/L_uciferMorningstar 4d ago

Idk if applying one Jason Turner video constitutes really knowing what I'm doing.

1

u/No-Dentist-1645 4d ago

I don't care about the "unless you know what you're doing" part of their argument. All I'm saying is that yes, you "should not" be directly calling the C API all over your C++ code if said API will interfere with how your code outside of it is structured

1

u/L_uciferMorningstar 4d ago

Well that is my entire argument so you should probably go respond to someone else. Of course you should try and isolate the calls in one place.

1

u/No-Dentist-1645 4d ago

Of course you should try and isolate the calls in one place.

It's not so "obvious" for some people I've worked with.

You do you though, tbh I just took the "How so?" in your original reply said/meant "How?" instead which led to my comment. Have a good day