In the small sample below:
#include
using namespace std;
int z(){
return 5 + 10; // returns 15
}
int main(){
z(); // what happens
In general: when a function returns a non-void value and the value does not get stored anywhere, the value is destroyed.
Specifically: natural datatypes, like ints and doubles, or pointers, don't have an explicit destructor, so nothing really happens. The returned value simply gets ignored.
If a function returns a class instance, the class instance gets destroyed, which results in an invocation of the class's defined destructor, or a default destructor.