How to know number 13 :-?

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
#include <iostream.h>
#include <conio.h>
class hamed{
   public:
      int a;
      int b;
           int show(){
             int c;
             c=a+b;
         cout<<c<<endl;
         getch();
           }
           void dob(); 
             };
void hamed::dob(){
     int ss=12;
cout<<"bay"<<endl<<"ss:"<<ss<<endl;
  return ;
     }
int main()
{
    hamed f;
    hamed w;
  f.a=1;
  f.b=2;
    f.show();
    w.dob();
hamed &q=f;
q.a=5;
q.show();
hamed *time=&f;
time->show();
~time->show();
cout<<(*time).show();
 return 0;
}


out:
3
bay
ss:12
7
7
7
7
13

How to know number 13 :-?
Last edited on
[code] "Please use code tags" [/code]
1
2
3
4
5
6
7
int show(){
  int c;
  c=a+b;
  cout<<c<<endl;
  getch();
  //return?
}
ok
thank you
Question
How calculated 13 ? (dev c++)
Last edited on
cout<<(*time).show(); is outputting the value returned by show. However in the show method there is no return statement.
So it's printing garbage.
gcc gives the warning
no return statement in function returning non-void


By the way, you may want to change your compiler http://www.cplusplus.com/forum/articles/36896/
Topic archived. No new replies allowed.