I would like to allocate a structure on the heap, initialize it and return a pointer to it from a function. I\'m wondering if there\'s a way for me to initialize const membe
I like caf's approach, but this occured to me too
ImmutablePoint* newImmutablePoint(int x, int y){ struct unconstpoint { int x; int y; } *p = malloc(sizeof(struct unconstpoint)); if (p) { // guard against malloc failure *p.x = x; *p.y = y; } return (ImmutablePoint*)p; }