Should return a value [-Wreturn-type]

i found this Error when i run my code
should return a value [-Wreturn-type] return;} “”

TH1D* Experement(TString filename)

expects a returned value. In your code you have two return statements without value.

sorry, i did not understand. Can you modify it in the code plz?

In your code you have 3 return statements.

one is ok. It returns something:

return h;

but the two others are just:


so nothing is returned. You should return something. That’s your code. It is up to you to decide what should be returned in these two cases.

in the first two return i just want the array read the next line from the data file, So what i have to write ?

so probably return is not the right statement.
return means exit the function.
You mean break may be ?

I found the mistake

in the first two return the code line have to be

while (inputfile >> E1 >> C1) {
1 Like

Yes break is better in that case :smiley:

No, Break in the end of Loop, i don’t change.

But in the place of return we have to write just {} “Empty brackets”. :wink:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.