Simplified question : Can I use the ternary operator in a new object declaration.
For example, if I have a two player game, and depending on whose turn it is:
classA { ... }
classB : classA {...}
classC : classA {...}
classA _Object = ((_turn % 2 == 0) ? new classB : new classC);
When I do this, I'm told that the operands are incompatible. I could have sworn that I've seen this working before, but I can't seem to get it to work. I tried restructuring and had the same results with this:
classA { ... }
classB : classA {...}
classC : classA {...}
classB cb;
classC cc;
classA _Object = ((_turn % 2 == 0) ? cb : cc);
Any insight would be appreciated. Thanks!