very tricky error. the problem lies somewhere in the defined class structure. in my case, i put the function inside the main method instead inside the members method .