That class is a bit funky because it initializes lnum
from an external variable. It really should come from an argument to the constructor. But since that’s the way it is, you can’t control it, other than by setting the value of lineNumber
, which probably isn’t what was intended; its value probably comes from wherever the input is being processed, and gets incremented at each new line.
So to create an object of that type, just do it:
Token t(T_ID, "this");
solved How to create an instance of a class given this definition