79251048

Date: 2024-12-04 11:58:02
Score: 1
Natty:
Report link

Thanks for the comments,my assumption was that arrays internally were no more than a special const * type that happened to point to a larger area of memory, clearly I was wrong.

(A scuffed "solution" that actually works)

void foo(){
        static const int * tree1[] = {
            new int[2]{FULL,1}, 
            new int[2]{FULL,2},
            new int[2]{EMPTY,4},
            new int[2]{EMPTY,5},
            new int[2]{EMPTY,3}
        };
        static const int * tree2[] = {
            new int[2]{FULL,1},
            new int[2]{EMPTY,2},
            new int[2]{FULL,3},
            new int[2]{LEFT,4},
            new int[2]{LEFT,5},
            new int[2]{EMPTY,6},
            new int[2]{RIGHT,7},
            new int[2]{RIGHT,8},
            new int[2]{EMPTY,9}
        };
        static const int ** whydoesthisnotwork[]= {tree1,tree2};
}
Reasons:
  • Blacklisted phrase (0.5): Thanks
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Luca Fiorini