Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
constructing object on first use as return value of (pointer to) object-returning function
//constructing object on first use as return value of (pointer to) object-returning function //g++ 5.4.0 //Coded by Twareintor (2020) #include <iostream> class CxxApplication { friend CxxApplication* application(); static CxxApplication* inst; public: CxxApplication(){std::cout<<"app opened\n";} ~CxxApplication(){std::cout<<"app closed\n";} void perform(){std::cout<<"app performing ... done\n";} void perform(int i){std::cout<<"app performing ... "<< i <<" times\n";} void close(){if(inst) delete inst;} }; CxxApplication* CxxApplication::inst = 0; CxxApplication* application() { if(!CxxApplication::inst) CxxApplication::inst = new CxxApplication(); return CxxApplication::inst; } int main() { application()->perform(); application()->perform(20); application()->close(); return 0; }
run
|
edit
|
history
|
help
0
BinomialPoisson
MovConstrAssign2
Travel Buddy
Cross Multiplication
ssss
dsadasdsa
Wipro Problem 2: determine count
generating all valid parenthesis
linkage
VecScalMultiOpLaod