Confused about the application of some OOP concepts.
Suppose I have a class called token.
Another class called Op (for operator) is derived from it.
Polymorphism says that objects of Op can be treated as a token.
But how do I use this when a somewhat reverse situation comes up?
For example:
I have a lexer function that takes in a big std::string and generates substrings which feed the constructor of token.
Is there a way, by which I can automatically make the value in question an Op(thus calling Op's constructor) depending on a check made by token's constructor ?