Please help ! :(

Error at cout<<duplicate(x, y, z);

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'void' (or there is no acceptable conversion)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
using namespace std;
#include<string>

int add(int i, int y){
int b;
 b=i+y;
return b;
}

void duplicate (int& a, int& b, int& c)
{
  a*=2;
  b*=2;
  c*=2;
}

int main ()
{
  int x=5, y=7, z=5;


  cout<< add(x, y)<<endl; // passing by value //value will be a copy of x in



  cout<<duplicate(x, y, z)<<endl;




  return 0;

  
}

Look at the difference between your first function and the second. Ask yourself, Why does this work
 
 cout<< add(x, y)<<endl;


but not this

cout<<duplicate(x, y, z)<<endl;
OHHHH I GET U !
Topic archived. No new replies allowed.