a basic output

could you please correct me what is wrong in this code

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
#include <iostream>
#include<conio.h>
using namespace std;

class degeral{
      
      int k,e,total;
      public:
             degeral(int x){
                         
                         k=x;
                         }
                           int hesapla(){
                cout<<"deger girin";
                cin>>e;
                total=k*e;
                return total;
                
                }
      
             
};
          void  goster(degeral a){
               a.hesapla();
              
               }
int main(){
 degeral x(5);
 cout<<goster(x);
    getch();
    
    return 0;
    }

goster has return type void so it doesn't return anything. It doesn't make sense to try to print it cout<<goster(x);. If you want goster to return something change the return type and return something.
hi peter i am pretty new to programming i dont know what changes should i make i am getting error at this point.how should it be
29 D:\c+++\k.cpp no match for 'operator<<' in 'std::cout << goster(x)'
goster() doesn't return a thing, not even int. the hesapla() returns an int to the goster() but it doesn't do anything... this code will make everything clear:

1
2
3
void goster (degeral a) {
     cout << a.hesapla();
}
Last edited on
What is it you want goster to return? You hjave already made hesapla return an int so it shouldn't be hard making goster return something too.
thank you friends
Topic archived. No new replies allowed.