[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Lua state as a C++ class ...
- From: Nick Trout <Nick.Trout@...>
- Date: Thu, 13 Jun 2002 11:02:04 +0100
> On Thu, Jun 13, 2002 at 10:37:07AM +0100, Nick Trout wrote:
> > Could you not just derive your state from Luas state struct
> and downcast?
> > Have I missed the point?
> Unless I'm completely wrong (as is my wont today for some
> reason) -- the
> lua_State which things outside of the VM know exists, is what
> is known as an
> "opaque type" in that we know a lua_State is a struct, and we
> always deal in
> pointers to it.
You are right. It was a silly idea :-)
Aggregation would be a better way to do it anyway and have reflective
pointer. If you are using Lua 4.0 then you'd have to modify the code, if you
are using 5.0 I think you just change a define to add data to the state. I
assume Alex is using 4.0 then.
> Also I'm not completely convinced that C++ allows you to
> inherit a class
> from a struct, although I could be wrong there too.
A struct in C++ is exactly the same as a class except the default access is
public, not private.