C
c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define new(T) T##_constructor ()
typedef struct A{
unsigned id;
char name[20];
} A;
typedef struct B{
unsigned id;
char name[20];
} B;
A* A_constructor(){
A * self=malloc(sizeof(A));
self->id=1;
strcpy(self->name,"A");
return self;
}
B* B_constructor(){
B* self=malloc(sizeof(B));
self->id=2;
strcpy(self->name,"B");
return self;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run