Hi,
I'm trying to figure out if the following code is correct or could cause problems in some way...
class MyClass {
...
};
MyClass doSomething() {
...
MyClass obj;
....
return obj;
}
int main() {
MyClass &ret = doSomething();
...
return 0;
}
So function doSomething() returns an object, and "ret" is referring to that object. The question is now whether "ret" refers to a valid object or not?
--
Knut Stolze
Data Warehousing for DB2 z/OS
IBM Germany Research & Development
I'm trying to figure out if the following code is correct or could cause problems in some way...
class MyClass {
...
};
MyClass doSomething() {
...
MyClass obj;
....
return obj;
}
int main() {
MyClass &ret = doSomething();
...
return 0;
}
So function doSomething() returns an object, and "ret" is referring to that object. The question is now whether "ret" refers to a valid object or not?
--
Knut Stolze
Data Warehousing for DB2 z/OS
IBM Germany Research & Development
Comment