dynamic variable in class and inheritance