0

What is the meaning if there is no value of return? Thanks

void run_algo() {
   ...
   project(tolabel->second);
   ...
}

void project(Projected &projected) {
    unsigned int sup = support(projected);
    if(sup < minsup) // minsup is a global variable
        return  ;
//-------------^--------->no expression here?    
    ...
}
Jason
  • 36,170
  • 5
  • 26
  • 60
LoveTW
  • 3,746
  • 12
  • 42
  • 52

7 Answers7

15

Since the type of your function is void, when you use return, it exits the function immediately and back to the caller.

Sango
  • 176
  • 3
8

The function is declared as returning void. So there is no value returned. Using return in this function just means this function is finished.

BoBTFish
  • 19,167
  • 3
  • 49
  • 76
3

It just exits the function immediately, returning to the caller.

Graham Borland
  • 60,055
  • 21
  • 138
  • 179
1

It means that the execution of this function ends at this point, and it does not continue to the following lines of code.

Ilya Kogan
  • 21,995
  • 15
  • 85
  • 141
1

It is used to exit from the function immediately. It resolves the necessity of an else statement in this case.

void project(Projected &projected) {
    unsigned int sup = support(projected);
    if(sup < minsup) // minsup is a global variable
        ;
    else {
        // ...
    }
}
Niklas R
  • 16,299
  • 28
  • 108
  • 203
1

Jump out from current function without returning value.

skywall
  • 3,956
  • 1
  • 34
  • 52
0

The return statement: Terminates the execution of a function and returns control to the calling function (or, in the case of the main function, transfers control back to the operating system). Execution resumes in the calling function at the point immediately following the call.

From msdn: http://msdn.microsoft.com/en-us/library/k68ktdwf%28v=vs.80%29.aspx