J
john smith
I am trying to override global new.
Yes, I know this is not a good idea, but I want to do it anyway. Notice
that I am not trying to override new in a class.
Any suggestions? I thought the below would work but it just goes into a
recursive call (infinite loop)
Is this not possible? ummm
Many thanks to any suggestions.
#include <iostream>
class car {
public:
car()
{
std::cout << "car " << std::endl;
}
int type;
};
int main()
{
car my_car;
car* p_my_car = new car();
return 0;
}
void* operator new( size_t my_size)
{
std::cout << "now grabbing some memory" << std::endl;
return :perator new( my_size );
}
Yes, I know this is not a good idea, but I want to do it anyway. Notice
that I am not trying to override new in a class.
Any suggestions? I thought the below would work but it just goes into a
recursive call (infinite loop)
Is this not possible? ummm
Many thanks to any suggestions.
#include <iostream>
class car {
public:
car()
{
std::cout << "car " << std::endl;
}
int type;
};
int main()
{
car my_car;
car* p_my_car = new car();
return 0;
}
void* operator new( size_t my_size)
{
std::cout << "now grabbing some memory" << std::endl;
return :perator new( my_size );
}