Better_Software_Header_MobileBetter_Software_Header_Web

Find what you need - explore our website and developer resources

Object Lifetime

auto& GetData(){
    const int i = 5;
    return i;
}
auto* GetData(){
    const char* i = "Hello";
    return i;
}
auto* GetData(){
    const char[] i = "Hello";
    return i;
}
struct S {
S(){}
~S(){}
};

int main(){S s;}
struct S {
S(int a){
    a = new MyWidgetNothrow(a);
    b = new MyWidgetThrows(a);
}
~S(){
   delete a;
   delete b;
}

MyWidget* a;
MyWidget* b;
};

int main(){S s;}
struct S {
S() = default;
S(int a):S{} {
a = new MyWidgetNothrow;
b = new MyWidgetThrows;
}
~S(){
delete a;
delete b;
}

MyWidget* a = nullptr;
MyWidget* b = nullptr;
};

int main(){S s;}

About KDAB