Created
May 18, 2012 07:55
-
-
Save dmikurube/2723839 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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