Re: Can Objects has multiple classes?



> Hello,
> 	I want to set a per instance property that causes that object to look
> up a vtable with slightly different semantics. The semantics of one
> instance should not interfere with another. This requires two different
> classes. The idea is to jump directly to the correct function without
> incurring the cost of constantly (typeA)? fun1() : fun2(); by setting
> the class pointer at initialization.

That doesn't seem like a high cost.

> I wish to avoid sub-classing the the semantics since the API is exactly
> the same, and it would cause an undue amount useless code.
>
> Is this possible with a minimum of hackishness?
>
> ps. If you'd like an example, consider a reverse iterator which is
> identical to forward iterator except next/prev functions are reversed.


Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]