+ 4
C++ Pointers to void?
i want to access void function with pointer. like this #include <iostream> using namespace std; void yay() {cout << "WORKS!\n";} int main() { void *acc; acc = yay(); //now i want yay is called and produce ouput return 0; } but of course its occur an error. how to do that?
4 Respuestas
+ 15
#include <iostream>
void yay()
{
std::cout << "WORKS!\n";
}
int main()
{
void (*acc)(void);
acc = yay;
return 0;
}
Further reading: Function pointers.
+ 1
std:: is the Standard call for c++ output. So if you use “using namespace std;” you wouldn’t have to use std::cout, you would just say cout << “hi” ;
0
and can you explain me, what is the mean std:: ?