- 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??

7th Sep 2017, 2:47 PM
Sudheer Tripathi
Sudheer Tripathi - avatar
5 Respuestas
+ 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.
7th Sep 2017, 2:56 PM
Atul Agrawal
7th Sep 2017, 2:59 PM
Manual
Manual - avatar
+ 5
I see the problem
7th Sep 2017, 2:54 PM
Manual
Manual - avatar
+ 2
Thanks @Manual and @Atul Aggarwal
7th Sep 2017, 3:14 PM
Sudheer Tripathi
Sudheer Tripathi - avatar
+ 1
You're welcome!
7th Sep 2017, 3:40 PM
Manual
Manual - avatar