原帖由 spibit 于 2007-7-23 14:54 发表
#define new(type) (type *)malloc(sizeof(type))
#define delete(ptr) free(ptr)
(这两个东西是不会调用构造函数和析构函数的。)
#include <stdio.h> #define new(type) (type *)malloc(sizeof(type)) int main() { char *str = new(char[10]); str[0] = '\0'; return 0; } |
原帖由 Mart1n 于 2007-7-24 11:32 发表
new(char[10]) ~~~ LOL
#include
#define new(type) (type *)malloc(sizeof(type))
int main()
{
char *str = new(char[10]);
str[0] = '\0 ...
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |