c++ - new operator with CArray results in an error -


i have following mfc (c++) code allocates pointer array without need raise exceptions in case of low memory condition. compile visual studio 2008.

struct my_item_info {     cstring str;     int n;      my_item_info()     {         n = 0;     } };  carray<my_item_info>* parrresitems = new (std::nothrow) carray<my_item_info>(); if(parrresitems != null) {     //got it!      //remove     delete parrresitems; } 

which gives me following error message on new operator line when try compile it:

error c2665: 'cobject::operator new' : none of 3 overloads convert argument types 'void *cobject::operator new(size_t,void *)' 

any idea how make compile?

ok. got it, new line should've been (or take new operator global namespace):

carray<my_item_info>* parrresitems = ::new (std::nothrow) carray<my_item_info>(); 

evidently new operator cobject not support nothrow_t.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -