Initialization of all elements of an array to one default value in C++?

C++ Notes: Array Initialization has a nice list over initialization of arrays. I have a int array[100] = {-1}; expecting it to be full with -1’s but its not, only first value is and the rest are 0’s mixed with random values. The code int array[100] = {0}; works just fine and sets each element … Read more

Named tuple and default values for optional keyword arguments

I’m trying to convert a longish hollow “data” class into a named tuple. My class currently looks like this: class Node(object): def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right After conversion to namedtuple it looks like: from collections import namedtuple Node = namedtuple(‘Node’, ‘val left right’) But there is … Read more