- 1
An error??
#include <iostream> using namespace std; void myFunc(int x) { x = 100; } int main() { int var = 20; cout<<myFunc(var); } A compilation error??
5 Answers
+ 6
when you print any value using cout you can only print a function which return a data type value..
in your program myFunction it returns void that is why it can not be directly access using cout.
instead of void use int or any other data type.
e.g. int myFunction(int x)
it will work perfect.
+ 6
Here is an example
https://code.sololearn.com/c0RrKig2CfI9/?ref=app
+ 5
I see the problem
+ 2
Thanks @Manual and @Atul Aggarwal
+ 1
You're welcome!