Memory allocation in while loop | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Memory allocation in while loop

Refer below code: #include <iostream> using namespace std; class Test { public: Test () {cout << "constructor" << endl;} ~Test () {cout << "destructor" << endl;} }; int main() { while(Test* obj = new Test()) { cout << "*****" <<endl; } return 0; } Above code is infinite loop as far as New operator allocates memory... Till what time i.e. how many memory allocation will succeed ?

20th Jul 2018, 4:44 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 Answer
0
It allocate memory while your OS allow to it
20th Jul 2018, 5:12 PM
KrOW
KrOW - avatar