rubbish results with Warning

I have 2 Warnings with illogical result. the result after debugging is
rubbish values
warning C4715: 'Circle_computations::set_r' : not all control paths return a value




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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
  #include<iostream>
using namespace std;

class Circle_computations
{

protected:
	double area,circumference,radius,pi;
	
public:


 Circle_computations()
{
 }	
  Circle_computations(double radi)
{
pi = 3.14;

set_r(radi);

}



  double set_r(double radi)
  {
  
try
{
if(radi<=0.0)
{
throw "PLESE ENTER positive NUMBERS";

}

radius=radi;


}

catch ( const char* strException )
    {
        cerr << "Error: " << strException << "\n";
        return 1 ;
		
    }








  }

double get_r()
{

return radius;

}



double circle_area()
{

area = pi*radius*radius;
return area;
 
}

double circle_circumferunce()
{

circumference =2*pi*radius;
return circumference;

}
void print_circleoutput()
{
cout<<"****The  Area OF The Circle  is****\n"<<area<<"\n";

cout<<"****The Circle Circumferunce is****\n"<<circumference<<"\n";

}





};

class Cylinder:public Circle_computations
{

protected:
	double height,volume,cyarea;

public:
Cylinder(double r, double h) :
    Circle_computations(r)
{
    set_height(h);
}

	

double set_height(double h)
  {
  
try
{
if(h<=0.0)
{
throw "PLESE ENTER positive NUMBERS";

}

height=h;


}

catch ( const char* strException )
    {
        cerr << "Error: " << strException << "\n";
        return 1 ;
		
    }




  }

double get_height()
{

return height;

}



	double cylindersurface_area()
{
	cyarea=(2 * (Circle_computations::circle_area()))+( circle_circumferunce()* height) ;

	return cyarea;

}


double c_volume()
{
	volume = (Circle_computations::circle_area())* height;

	return volume;

}


void print_cylinderoutput()
{
cout<<"****The cylinder surface  Area   is****\n"<<cyarea;;

cout<<"****The cylinder volume   is****\n"<<volume;
}


};


int main()

{

Circle_computations  compute(1.5);
Cylinder computecylider(1.5,2.5);
cout<<"****The  Radius  is****\n";

computecylider.get_height();
computecylider.get_r();
computecylider.set_r(3.5);
computecylider.set_height(2.6);
computecylider.print_cylinderoutput();


}
closed account (9wqjE3v7)
You have not specified a return value for the regular control flow of the functions. Immediately after your exception handler you need to include a return value. Why are you using exceptions?
Last edited on
Topic archived. No new replies allowed.