Skip to content

Instantly share code, notes, and snippets.

@dmikurube
Created May 18, 2012 07:55
Show Gist options
  • Save dmikurube/2723839 to your computer and use it in GitHub Desktop.
Save dmikurube/2723839 to your computer and use it in GitHub Desktop.
#include <cstddef>
void* operator new(size_t size, int dummy) {
return ::operator new(size);
}
class Class {
public:
Class() : x_(0) {}
void* operator new(size_t size) {
return ::operator new(size);
}
private:
int x_;
};
int main() {
Class* k;
// error: no matching function for call to ‘Class::operator new(long unsigned int, int)’
k = new(12) Class();
delete k;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment