+ 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 Resposta
0
It allocate memory while your OS allow to it
20th Jul 2018, 5:12 PM
KrOW
KrOW - avatar